diff options
author | Raymond Auge | 2016-05-13 19:43:36 +0000 |
---|---|---|
committer | Raymond Auge | 2016-05-13 19:43:36 +0000 |
commit | 455f9cefc23966584335cfe679a09e45ecf3a93d (patch) | |
tree | a47b78b1e812fede7a62d991f8f8e97e4fdaf8cf /bundles/org.eclipse.equinox.http.servlet | |
parent | 1593ffc5311c0257888cb9272ffb05f075eee717 (diff) | |
download | rt.equinox.bundles-455f9cefc23966584335cfe679a09e45ecf3a93d.tar.gz rt.equinox.bundles-455f9cefc23966584335cfe679a09e45ecf3a93d.tar.xz rt.equinox.bundles-455f9cefc23966584335cfe679a09e45ecf3a93d.zip |
Bug 490608 - [http servlet] simplify, make sure we only wrap once and testI20160516-2000I20160515-2000I20160514-1500I20160513-2000
Signed-off-by: Raymond Auge <raymond.auge@liferay.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.http.servlet')
-rw-r--r-- | bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java index f98512250..9db1bbfff 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java @@ -104,7 +104,9 @@ public class DispatchTargets { HttpServletRequest request = originalRequest; HttpServletRequestWrapperImpl requestWrapper = HttpServletRequestWrapperImpl.findHttpRuntimeRequest(originalRequest); - HttpServletResponse responseWrapper = HttpServletResponseWrapperImpl.findHttpRuntimeResponse(response); + HttpServletResponseWrapper responseWrapper = HttpServletResponseWrapperImpl.findHttpRuntimeResponse(response); + + boolean includeWrapperAdded = false; try { if (requestWrapper == null) { @@ -119,18 +121,10 @@ public class DispatchTargets { requestWrapper.push(this); - if (dispatcherType == DispatcherType.INCLUDE) { - HttpServletResponse previous = null; - HttpServletResponse next = response; - - while (next instanceof HttpServletResponseWrapper) { - previous = next; - next = (HttpServletResponse) ((HttpServletResponseWrapper) next).getResponse(); - } - - IncludeDispatchResponseWrapper includeResponse = new IncludeDispatchResponseWrapper(next); - - ((HttpServletResponseWrapper) previous).setResponse(includeResponse); + if ((dispatcherType == DispatcherType.INCLUDE) && !(responseWrapper.getResponse() instanceof IncludeDispatchResponseWrapper)) { + // add the include wrapper to avoid header and status writes + responseWrapper.setResponse(new IncludeDispatchResponseWrapper((HttpServletResponse)responseWrapper.getResponse())); + includeWrapperAdded = true; } ResponseStateHandler responseStateHandler = new ResponseStateHandler(request, response, this); @@ -138,6 +132,11 @@ public class DispatchTargets { responseStateHandler.processRequest(); } finally { + if ((dispatcherType == DispatcherType.INCLUDE) && (responseWrapper.getResponse() instanceof IncludeDispatchResponseWrapper) && includeWrapperAdded) { + // remove the include wrapper we added + responseWrapper.setResponse(((IncludeDispatchResponseWrapper)responseWrapper.getResponse()).getResponse()); + } + requestWrapper.pop(); setter.close(); |