Java Code Examples for org.apache.http.HttpResponse#removeHeaders()
The following examples show how to use
org.apache.http.HttpResponse#removeHeaders() .
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: AtlasApiHaDispatch.java From knox with Apache License 2.0 | 6 votes |
@Override protected void executeRequest(HttpUriRequest outboundRequest, HttpServletRequest inboundRequest, HttpServletResponse outboundResponse) throws IOException { HttpResponse inboundResponse = null; try { inboundResponse = executeOutboundRequest(outboundRequest); int statusCode = inboundResponse.getStatusLine().getStatusCode(); Header originalLocationHeader = inboundResponse.getFirstHeader("Location"); if ((statusCode == HttpServletResponse.SC_MOVED_TEMPORARILY || statusCode == HttpServletResponse.SC_TEMPORARY_REDIRECT) && originalLocationHeader != null) { inboundResponse.removeHeaders("Location"); failoverRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, new Exception("Atlas HA redirection")); } writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse, inboundResponse); } catch (IOException e) { LOG.errorConnectingToServer(outboundRequest.getURI().toString(), e); failoverRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, e); } }
Example 2
Source File: AtlasApiTrustedProxyHaDispatch.java From knox with Apache License 2.0 | 6 votes |
@Override protected void executeRequest(HttpUriRequest outboundRequest, HttpServletRequest inboundRequest, HttpServletResponse outboundResponse) throws IOException { HttpResponse inboundResponse = null; try { inboundResponse = executeOutboundRequest(outboundRequest); int statusCode = inboundResponse.getStatusLine().getStatusCode(); Header originalLocationHeader = inboundResponse.getFirstHeader("Location"); if ((statusCode == HttpServletResponse.SC_MOVED_TEMPORARILY || statusCode == HttpServletResponse.SC_TEMPORARY_REDIRECT) && originalLocationHeader != null) { inboundResponse.removeHeaders("Location"); failoverRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, new Exception("Atlas HA redirection")); } writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse, inboundResponse); } catch (IOException e) { LOG.errorConnectingToServer(outboundRequest.getURI().toString(), e); failoverRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, e); } }
Example 3
Source File: AtlasHaDispatch.java From knox with Apache License 2.0 | 5 votes |
@Override protected void executeRequest(HttpUriRequest outboundRequest, HttpServletRequest inboundRequest, HttpServletResponse outboundResponse) throws IOException { HttpResponse inboundResponse = null; try { inboundResponse = executeOutboundRequest(outboundRequest); int sc = inboundResponse.getStatusLine().getStatusCode(); if(sc == HttpServletResponse.SC_MOVED_TEMPORARILY || sc == HttpServletResponse.SC_TEMPORARY_REDIRECT) { if(!isLoginRedirect(inboundResponse.getFirstHeader("Location"))) { inboundResponse.removeHeaders("Location"); failoverRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, new Exception("Atlas HA redirection")); } } writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse, inboundResponse); } catch (IOException e) { LOG.errorConnectingToServer(outboundRequest.getURI().toString(), e); failoverRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, e); } }
Example 4
Source File: AtlasTrustedProxyHaDispatch.java From knox with Apache License 2.0 | 5 votes |
@Override protected void executeRequest(HttpUriRequest outboundRequest, HttpServletRequest inboundRequest, HttpServletResponse outboundResponse) throws IOException { HttpResponse inboundResponse = null; try { inboundResponse = executeOutboundRequest(outboundRequest); int sc = inboundResponse.getStatusLine().getStatusCode(); if (sc == HttpServletResponse.SC_MOVED_TEMPORARILY || sc == HttpServletResponse.SC_TEMPORARY_REDIRECT) { if (!isLoginRedirect(inboundResponse.getFirstHeader("Location"))) { inboundResponse.removeHeaders("Location"); failoverRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, new Exception("Atlas HA redirection")); } } writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse, inboundResponse); } catch (IOException e) { LOG.errorConnectingToServer(outboundRequest.getURI().toString(), e); failoverRequest(outboundRequest, inboundRequest, outboundResponse, inboundResponse, e); } }
Example 5
Source File: Surrogate.java From esigate with Apache License 2.0 | 5 votes |
/** * Remove Surrogate-Control header or replace by its new value. * * @param response * backend HTTP response. * @param keepHeader * should the Surrogate-Control header be forwarded to the client. */ private static void processSurrogateControlContent(HttpResponse response, boolean keepHeader) { if (!response.containsHeader(H_SURROGATE_CONTROL)) { return; } if (!keepHeader) { response.removeHeaders(H_SURROGATE_CONTROL); return; } MoveResponseHeader.moveHeader(response, H_X_NEXT_SURROGATE_CONTROL, H_SURROGATE_CONTROL); }
Example 6
Source File: MoveResponseHeader.java From esigate with Apache License 2.0 | 5 votes |
/** * This method can be used directly to move an header. * * @param response * HTTP response * @param srcName * source header name * @param targetName * target header name */ public static void moveHeader(HttpResponse response, String srcName, String targetName) { if (response.containsHeader(srcName)) { LOG.info("Moving header {} to {}", srcName, targetName); Header[] headers = response.getHeaders(srcName); response.removeHeaders(targetName); for (Header h : headers) { response.addHeader(targetName, h.getValue()); } response.removeHeaders(srcName); } }
Example 7
Source File: ResponseProtocolCompliance.java From apigee-android-sdk with Apache License 2.0 | 4 votes |
private void removeResponseTransferEncoding(HttpResponse response) { response.removeHeaders("TE"); response.removeHeaders(HTTP.TRANSFER_ENCODING); }