Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2015-11-05 09:51:44 -0500
committerSimone Bordet2015-11-05 09:51:44 -0500
commite0963543d28087d7295476dbfa3d5b6e17ea339d (patch)
tree9c0d55aea4228be9833a4ddfc0cc26dcc46a669b
parent4cf308a7db1d5399ec2b85e27211a7b54efd1561 (diff)
downloadorg.eclipse.jetty.project-e0963543d28087d7295476dbfa3d5b6e17ea339d.tar.gz
org.eclipse.jetty.project-e0963543d28087d7295476dbfa3d5b6e17ea339d.tar.xz
org.eclipse.jetty.project-e0963543d28087d7295476dbfa3d5b6e17ea339d.zip
476641 - Proxy rewriteTarget() null return does not call error handler.
Introduced sendProxyResponseError(), centralizing the place where an error is returned to the client, so that applications may override the behavior.
-rw-r--r--jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java28
1 files changed, 16 insertions, 12 deletions
diff --git a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
index bd2f0cb590..5e872d4f18 100644
--- a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
+++ b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
@@ -413,11 +413,11 @@ public abstract class AbstractProxyServlet extends HttpServlet
* like {@link HttpServletResponse#sendError(int)}.</p>
*
* @param clientRequest the client request
- * @param clientResponse the client response
+ * @param proxyResponse the client response
*/
- protected void onProxyRewriteFailed(HttpServletRequest clientRequest, HttpServletResponse clientResponse)
+ protected void onProxyRewriteFailed(HttpServletRequest clientRequest, HttpServletResponse proxyResponse)
{
- clientResponse.setStatus(HttpServletResponse.SC_FORBIDDEN);
+ sendProxyResponseError(clientRequest, proxyResponse, HttpStatus.FORBIDDEN_403);
}
protected boolean hasContent(HttpServletRequest clientRequest)
@@ -549,8 +549,7 @@ public abstract class AbstractProxyServlet extends HttpServlet
int status = failure instanceof TimeoutException ?
HttpStatus.REQUEST_TIMEOUT_408 :
HttpStatus.INTERNAL_SERVER_ERROR_500;
- proxyResponse.setStatus(status);
- clientRequest.getAsyncContext().complete();
+ sendProxyResponseError(clientRequest, proxyResponse, status);
}
}
@@ -636,13 +635,10 @@ public abstract class AbstractProxyServlet extends HttpServlet
else
{
proxyResponse.resetBuffer();
- if (failure instanceof TimeoutException)
- proxyResponse.setStatus(HttpServletResponse.SC_GATEWAY_TIMEOUT);
- else
- proxyResponse.setStatus(HttpServletResponse.SC_BAD_GATEWAY);
- proxyResponse.setHeader(HttpHeader.CONNECTION.asString(), HttpHeaderValue.CLOSE.asString());
- AsyncContext asyncContext = clientRequest.getAsyncContext();
- asyncContext.complete();
+ int status = failure instanceof TimeoutException ?
+ HttpStatus.GATEWAY_TIMEOUT_504 :
+ HttpStatus.BAD_GATEWAY_502;
+ sendProxyResponseError(clientRequest, proxyResponse, status);
}
}
@@ -651,6 +647,14 @@ public abstract class AbstractProxyServlet extends HttpServlet
return System.identityHashCode(clientRequest);
}
+ protected void sendProxyResponseError(HttpServletRequest clientRequest, HttpServletResponse proxyResponse, int status)
+ {
+ proxyResponse.setStatus(status);
+ proxyResponse.setHeader(HttpHeader.CONNECTION.asString(), HttpHeaderValue.CLOSE.asString());
+ if (clientRequest.isAsyncStarted())
+ clientRequest.getAsyncContext().complete();
+ }
+
/**
* <p>Utility class that implement transparent proxy functionalities.</p>
* <p>Configuration parameters:</p>

Back to the top