Java Code Examples for org.littleshoot.proxy.HttpFilters#proxyToClientResponse()
The following examples show how to use
org.littleshoot.proxy.HttpFilters#proxyToClientResponse() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BrowserUpHttpFilterChain.java From browserup-proxy with Apache License 2.0 | 6 votes |
@Override public HttpObject proxyToClientResponse(HttpObject httpObject) { HttpObject processedHttpObject = httpObject; for (HttpFilters filter : filters) { try { processedHttpObject = filter.proxyToClientResponse(processedHttpObject); if (processedHttpObject == null) { return null; } } catch (RuntimeException e) { log.warn("Filter in filter chain threw exception. Filter method may have been aborted.", e); } } return processedHttpObject; }
Example 2
Source File: BrowserMobHttpFilterChain.java From CapturePacket with MIT License | 6 votes |
@Override public HttpObject proxyToClientResponse(HttpObject httpObject) { HttpObject processedHttpObject = httpObject; for (HttpFilters filter : filters) { try { processedHttpObject = filter.proxyToClientResponse(processedHttpObject); if (processedHttpObject == null) { return null; } } catch (RuntimeException e) { log.warn("Filter in filter chain threw exception. Filter method may have been aborted.", e); } } return processedHttpObject; }
Example 3
Source File: BrowserMobHttpFilterChain.java From Dream-Catcher with MIT License | 6 votes |
@Override public HttpObject proxyToClientResponse(HttpObject httpObject) { HttpObject processedHttpObject = httpObject; for (HttpFilters filter : filters) { try { processedHttpObject = filter.proxyToClientResponse(processedHttpObject); if (processedHttpObject == null) { return null; } } catch (RuntimeException e) { log.warn("Filter in filter chain threw exception. Filter method may have been aborted.", e); } } return processedHttpObject; }
Example 4
Source File: BrowserMobHttpFilterChain.java From AndroidHttpCapture with MIT License | 6 votes |
@Override public HttpObject proxyToClientResponse(HttpObject httpObject) { HttpObject processedHttpObject = httpObject; for (HttpFilters filter : filters) { try { processedHttpObject = filter.proxyToClientResponse(processedHttpObject); if (processedHttpObject == null) { return null; } } catch (RuntimeException e) { log.warn("Filter in filter chain threw exception. Filter method may have been aborted.", e); } } return processedHttpObject; }
Example 5
Source File: ClientToProxyConnection.java From g4proxy with Apache License 2.0 | 4 votes |
/** * Send a response to the client. * * @param serverConnection * the ProxyToServerConnection that's responding * @param filters * the filters to apply to the response * @param currentHttpRequest * the HttpRequest that prompted this response * @param currentHttpResponse * the HttpResponse corresponding to this data (when doing * chunked transfers, this is the initial HttpResponse object * that came in before the other chunks) * @param httpObject * the data with which to respond */ void respond(ProxyToServerConnection serverConnection, HttpFilters filters, HttpRequest currentHttpRequest, HttpResponse currentHttpResponse, HttpObject httpObject) { // we are sending a response to the client, so we are done handling this request this.currentRequest = null; httpObject = filters.serverToProxyResponse(httpObject); if (httpObject == null) { forceDisconnect(serverConnection); return; } if (httpObject instanceof HttpResponse) { HttpResponse httpResponse = (HttpResponse) httpObject; // if this HttpResponse does not have any means of signaling the end of the message body other than closing // the connection, convert the message to a "Transfer-Encoding: chunked" HTTP response. This avoids the need // to close the client connection to indicate the end of the message. (Responses to HEAD requests "must be" empty.) if (!ProxyUtils.isHEAD(currentHttpRequest) && !ProxyUtils.isResponseSelfTerminating(httpResponse)) { // if this is not a FullHttpResponse, duplicate the HttpResponse from the server before sending it to // the client. this allows us to set the Transfer-Encoding to chunked without interfering with netty's // handling of the response from the server. if we modify the original HttpResponse from the server, // netty will not generate the appropriate LastHttpContent when it detects the connection closure from // the server (see HttpObjectDecoder#decodeLast). (This does not apply to FullHttpResponses, for which // netty already generates the empty final chunk when Transfer-Encoding is chunked.) if (!(httpResponse instanceof FullHttpResponse)) { HttpResponse duplicateResponse = ProxyUtils.duplicateHttpResponse(httpResponse); // set the httpObject and httpResponse to the duplicated response, to allow all other standard processing // (filtering, header modification for proxying, etc.) to be applied. httpObject = httpResponse = duplicateResponse; } HttpHeaders.setTransferEncodingChunked(httpResponse); } fixHttpVersionHeaderIfNecessary(httpResponse); modifyResponseHeadersToReflectProxying(httpResponse); } httpObject = filters.proxyToClientResponse(httpObject); if (httpObject == null) { forceDisconnect(serverConnection); return; } write(httpObject); if (ProxyUtils.isLastChunk(httpObject)) { writeEmptyBuffer(); } closeConnectionsAfterWriteIfNecessary(serverConnection, currentHttpRequest, currentHttpResponse, httpObject); }