@Test public void captureRequest() throws IOException { String bodyContent = "hello, world"; Charset bodyCharset = StandardCharsets.UTF_8; ByteBuf content = Unpooled.wrappedBuffer(bodyContent.getBytes(bodyCharset)); String url = "http: DefaultFullHttpRequest littleRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url, content); String contentType = MediaType.PLAIN_TEXT_UTF_8.withCharset(bodyCharset).toString(); littleRequest.headers().set(HttpHeaders.CONTENT_TYPE, contentType); BmpResponseManufacturer.WithState bmprmws = EasyMock.createMock(BmpResponseManufacturer.WithState.class); BmpResponseListener bmprl = EasyMock.createMock(BmpResponseListener.class); ResponseManufacturingFilter filter = new ResponseManufacturingFilter(littleRequest, createChannelHandlerContext(false), bmprmws, bmprl); filter.captureRequest(littleRequest); RequestCapture bmpRequest = filter.freezeRequestCapture(); ParsedRequest actual = bmpRequest.request; byte[] actualBody; try (InputStream bodyIn = actual.openBodyStream()) { actualBody = ByteStreams.toByteArray(bodyIn); } assertEquals("body", bodyContent, new String(actualBody, bodyCharset)); assertEquals("method", "POST", actual.method.name()); assertEquals("url", url, actual.url.toString()); assertEquals("content-type header", contentType, actual.getFirstHeaderValue(HttpHeaders.CONTENT_TYPE)); }
protected void captureRequest(HttpObject httpObject) { requestCaptureFilter.clientToProxyRequest(httpObject); if (httpObject instanceof HttpRequest) { HttpRequest httpRequest = (HttpRequest) httpObject; captureMethodAndUrl(httpRequest); captureRequestHeaders(httpRequest); } if (httpObject instanceof LastHttpContent) { LastHttpContent lastHttpContent = (LastHttpContent) httpObject; captureTrailingHeaders(lastHttpContent); captureRequestContent(requestCaptureFilter.getFullRequestContents()); } }
ResponseManufacturingFilter extends HttpsAwareFiltersAdapter { protected void captureRequest(HttpObject httpObject) { requestCaptureFilter.clientToProxyRequest(httpObject); if (httpObject instanceof HttpRequest) { HttpRequest httpRequest = (HttpRequest) httpObject; captureMethodAndUrl(httpRequest); captureRequestHeaders(httpRequest); } if (httpObject instanceof LastHttpContent) { LastHttpContent lastHttpContent = (LastHttpContent) httpObject; captureTrailingHeaders(lastHttpContent); captureRequestContent(requestCaptureFilter.getFullRequestContents()); } } }
ResponseManufacturingFilter extends HttpsAwareFiltersAdapter { protected void captureRequest(HttpObject httpObject) { requestCaptureFilter.clientToProxyRequest(httpObject); if (httpObject instanceof HttpRequest) { HttpRequest httpRequest = (HttpRequest) httpObject; captureMethodAndUrl(httpRequest); captureRequestHeaders(httpRequest); } if (httpObject instanceof LastHttpContent) { LastHttpContent lastHttpContent = (LastHttpContent) httpObject; captureTrailingHeaders(lastHttpContent); captureRequestContent(requestCaptureFilter.getFullRequestContents()); } } <S> ResponseManufacturingFilter(HttpRequest originalRequest, ChannelHandlerContext ctx, BmpResponseManufacturer.WithState<S> responseManufacturer, BmpResponseListener responseListener); }
ResponseManufacturingFilter extends HttpsAwareFiltersAdapter { protected void captureRequest(HttpObject httpObject) { requestCaptureFilter.clientToProxyRequest(httpObject); if (httpObject instanceof HttpRequest) { HttpRequest httpRequest = (HttpRequest) httpObject; captureMethodAndUrl(httpRequest); captureRequestHeaders(httpRequest); } if (httpObject instanceof LastHttpContent) { LastHttpContent lastHttpContent = (LastHttpContent) httpObject; captureTrailingHeaders(lastHttpContent); captureRequestContent(requestCaptureFilter.getFullRequestContents()); } } <S> ResponseManufacturingFilter(HttpRequest originalRequest, ChannelHandlerContext ctx, BmpResponseManufacturer.WithState<S> responseManufacturer, BmpResponseListener responseListener); @Override HttpResponse clientToProxyRequest(HttpObject httpObject); @Override final HttpObject proxyToClientResponse(HttpObject httpObject); @Override HttpObject serverToProxyResponse(HttpObject httpObject); @Override void proxyToServerResolutionSucceeded(String serverHostAndPort, InetSocketAddress resolvedRemoteAddress); @Override void proxyToServerRequestSending(); @Override void proxyToServerResolutionFailed(String hostAndPort); @Override void proxyToServerConnectionFailed(); @Override void serverToProxyResponseTimedOut(); @Override HttpResponse proxyToServerRequest(HttpObject httpObject); @Override void proxyToServerRequestSent(); @Override void serverToProxyResponseReceiving(); @Override void serverToProxyResponseReceived(); @Override void proxyToServerConnectionQueued(); @Override InetSocketAddress proxyToServerResolutionStarted(String resolvingServerHostAndPort); @Override void proxyToServerConnectionStarted(); @Override void proxyToServerConnectionSSLHandshakeStarted(); @Override void proxyToServerConnectionSucceeded(ChannelHandlerContext serverCtx); }
ResponseManufacturingFilter extends HttpsAwareFiltersAdapter { protected void captureRequest(HttpObject httpObject) { requestCaptureFilter.clientToProxyRequest(httpObject); if (httpObject instanceof HttpRequest) { HttpRequest httpRequest = (HttpRequest) httpObject; captureMethodAndUrl(httpRequest); captureRequestHeaders(httpRequest); } if (httpObject instanceof LastHttpContent) { LastHttpContent lastHttpContent = (LastHttpContent) httpObject; captureTrailingHeaders(lastHttpContent); captureRequestContent(requestCaptureFilter.getFullRequestContents()); } } <S> ResponseManufacturingFilter(HttpRequest originalRequest, ChannelHandlerContext ctx, BmpResponseManufacturer.WithState<S> responseManufacturer, BmpResponseListener responseListener); @Override HttpResponse clientToProxyRequest(HttpObject httpObject); @Override final HttpObject proxyToClientResponse(HttpObject httpObject); @Override HttpObject serverToProxyResponse(HttpObject httpObject); @Override void proxyToServerResolutionSucceeded(String serverHostAndPort, InetSocketAddress resolvedRemoteAddress); @Override void proxyToServerRequestSending(); @Override void proxyToServerResolutionFailed(String hostAndPort); @Override void proxyToServerConnectionFailed(); @Override void serverToProxyResponseTimedOut(); @Override HttpResponse proxyToServerRequest(HttpObject httpObject); @Override void proxyToServerRequestSent(); @Override void serverToProxyResponseReceiving(); @Override void serverToProxyResponseReceived(); @Override void proxyToServerConnectionQueued(); @Override InetSocketAddress proxyToServerResolutionStarted(String resolvingServerHostAndPort); @Override void proxyToServerConnectionStarted(); @Override void proxyToServerConnectionSSLHandshakeStarted(); @Override void proxyToServerConnectionSucceeded(ChannelHandlerContext serverCtx);  }