@Override public HttpResponse clientToProxyRequest(HttpObject httpObject) { if (proxyServer.isStopped()) { log.warn("Aborting request to {} because proxy is stopped", originalRequest.getUri()); HttpResponse abortedResponse = new DefaultFullHttpResponse(originalRequest.getProtocolVersion(), HttpResponseStatus.SERVICE_UNAVAILABLE); HttpHeaders.setContentLength(abortedResponse, 0L); return abortedResponse; } for (HttpFilters filter : filters) { try { HttpResponse filterResponse = filter.clientToProxyRequest(httpObject); if (filterResponse != null) { // if we are short-circuiting the response to an HttpRequest, update ModifiedRequestAwareFilter instances // with this (possibly) modified HttpRequest before returning the short-circuit response if (httpObject instanceof HttpRequest) { updateFiltersWithModifiedResponse((HttpRequest) httpObject); } return filterResponse; } } catch (RuntimeException e) { log.warn("Filter in filter chain threw exception. Filter method may have been aborted.", e); } } // if this httpObject is the HTTP request, set the modified request object on all ModifiedRequestAwareFilter // instances, so they have access to all modifications the request filters made while filtering if (httpObject instanceof HttpRequest) { updateFiltersWithModifiedResponse((HttpRequest) httpObject); } return null; }
@Override public HttpResponse clientToProxyRequest(HttpObject httpObject) { if ( httpObject instanceof HttpRequest ) { HttpRequest httpRequest = (HttpRequest)httpObject; // if ( ! httpRequest.getUri().startsWith( "http" ) ) { // // } } return delegate.clientToProxyRequest( httpObject ); }
@Override public HttpResponse clientToProxyRequest(HttpObject httpObject) { if ( httpObject instanceof HttpRequest ) { this.httpRequest = (HttpRequest)httpObject; // add HTTP headers if required... if ( listener.getRequestHeaders() != null ) { for (Map.Entry<String, String> header : listener.getRequestHeaders().entrySet()) { this.httpRequest.headers().add( header.getKey(), header.getValue() ); } } } return delegate.clientToProxyRequest( httpObject ); }
@Override protected void readHTTPChunk(HttpContent chunk) { currentFilters.clientToProxyRequest(chunk); currentFilters.proxyToServerRequest(chunk); currentServerConnection.write(chunk); }
@Override protected void readHTTPChunk(HttpContent chunk) { currentFilters.clientToProxyRequest(chunk); currentFilters.proxyToServerRequest(chunk); currentServerConnection.write(chunk); }
@Override protected void readHTTPChunk(HttpContent chunk) { HttpResponse clientToProxyFilterResponse = currentFilters.clientToProxyRequest(chunk); if (clientToProxyFilterResponse != null) { LOG.debug("Responding to client with short-circuit response from filter: {}", clientToProxyFilterResponse); respondWithShortCircuitResponse(clientToProxyFilterResponse); }else { currentFilters.proxyToServerRequest(chunk); currentServerConnection.write(chunk); } }
@Override public HttpResponse clientToProxyRequest(HttpObject httpObject) { if (proxyServer.isStopped()) { log.warn("Aborting request to {} because proxy is stopped", originalRequest.getUri()); HttpResponse abortedResponse = new DefaultFullHttpResponse(originalRequest.getProtocolVersion(), HttpResponseStatus.SERVICE_UNAVAILABLE); HttpHeaders.setContentLength(abortedResponse, 0L); return abortedResponse; } for (HttpFilters filter : filters) { try { HttpResponse filterResponse = filter.clientToProxyRequest(httpObject); if (filterResponse != null) { // if we are short-circuiting the response to an HttpRequest, update ModifiedRequestAwareFilter instances // with this (possibly) modified HttpRequest before returning the short-circuit response if (httpObject instanceof HttpRequest) { updateFiltersWithModifiedResponse((HttpRequest) httpObject); } return filterResponse; } } catch (RuntimeException e) { log.warn("Filter in filter chain threw exception. Filter method may have been aborted.", e); } } // if this httpObject is the HTTP request, set the modified request object on all ModifiedRequestAwareFilter // instances, so they have access to all modifications the request filters made while filtering if (httpObject instanceof HttpRequest) { updateFiltersWithModifiedResponse((HttpRequest) httpObject); } return null; }
@Override public HttpResponse clientToProxyRequest(HttpObject httpObject) { if (proxyServer.isStopped()) { log.warn("Aborting request to {} because proxy is stopped", originalRequest.getUri()); HttpResponse abortedResponse = new DefaultFullHttpResponse(originalRequest.getProtocolVersion(), HttpResponseStatus.SERVICE_UNAVAILABLE); HttpHeaders.setContentLength(abortedResponse, 0L); return abortedResponse; } for (HttpFilters filter : filters) { try { HttpResponse filterResponse = filter.clientToProxyRequest(httpObject); if (filterResponse != null) { // if we are short-circuiting the response to an HttpRequest, update ModifiedRequestAwareFilter instances // with this (possibly) modified HttpRequest before returning the short-circuit response if (httpObject instanceof HttpRequest) { updateFiltersWithModifiedResponse((HttpRequest) httpObject); } return filterResponse; } } catch (RuntimeException e) { log.warn("Filter in filter chain threw exception. Filter method may have been aborted.", e); } } // if this httpObject is the HTTP request, set the modified request object on all ModifiedRequestAwareFilter // instances, so they have access to all modifications the request filters made while filtering if (httpObject instanceof HttpRequest) { updateFiltersWithModifiedResponse((HttpRequest) httpObject); } return null; }
@Override public HttpResponse clientToProxyRequest(HttpObject httpObject) { if (proxyServer.isStopped()) { log.warn("Aborting request to {} because proxy is stopped", originalRequest.getUri()); HttpResponse abortedResponse = new DefaultFullHttpResponse(originalRequest.getProtocolVersion(), HttpResponseStatus.SERVICE_UNAVAILABLE); HttpHeaders.setContentLength(abortedResponse, 0L); return abortedResponse; } for (HttpFilters filter : filters) { try { HttpResponse filterResponse = filter.clientToProxyRequest(httpObject); if (filterResponse != null) { // if we are short-circuiting the response to an HttpRequest, update ModifiedRequestAwareFilter instances // with this (possibly) modified HttpRequest before returning the short-circuit response if (httpObject instanceof HttpRequest) { updateFiltersWithModifiedResponse((HttpRequest) httpObject); } return filterResponse; } } catch (RuntimeException e) { log.warn("Filter in filter chain threw exception. Filter method may have been aborted.", e); } } // if this httpObject is the HTTP request, set the modified request object on all ModifiedRequestAwareFilter // instances, so they have access to all modifications the request filters made while filtering if (httpObject instanceof HttpRequest) { updateFiltersWithModifiedResponse((HttpRequest) httpObject); } return null; }
HttpResponse clientToProxyFilterResponse = currentFilters.clientToProxyRequest(httpRequest);
HttpResponse clientToProxyFilterResponse = currentFilters.clientToProxyRequest(httpRequest);
HttpResponse clientToProxyFilterResponse = currentFilters.clientToProxyRequest(httpRequest);