diff options
author | Raymond Auge | 2015-08-12 18:48:26 +0000 |
---|---|---|
committer | Raymond Auge | 2015-08-12 18:48:26 +0000 |
commit | 14b77e49a4a25351725b3dad145f24c2b2cb141b (patch) | |
tree | 2976a89b708486533496979342c250433b0df9c5 /bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java | |
parent | 9768ce0f3ebc232ec78118b986350cc589681022 (diff) | |
download | rt.equinox.bundles-14b77e49a4a25351725b3dad145f24c2b2cb141b.tar.gz rt.equinox.bundles-14b77e49a4a25351725b3dad145f24c2b2cb141b.tar.xz rt.equinox.bundles-14b77e49a4a25351725b3dad145f24c2b2cb141b.zip |
Bug 467859 - [http whiteboard] request/response wrappers are not visible ...
... during later request processing
Signed-off-by: Raymond Auge <raymond.auge@liferay.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java')
-rw-r--r-- | bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java | 64 |
1 files changed, 63 insertions, 1 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 2a2519c9f..79956aca8 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014 Raymond Augé and others. + * Copyright (c) 2014, 2015 Raymond Augé and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,10 +11,15 @@ package org.eclipse.equinox.http.servlet.internal.context; +import java.io.IOException; import java.util.Collections; import java.util.List; +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration; import org.eclipse.equinox.http.servlet.internal.registration.FilterRegistration; +import org.eclipse.equinox.http.servlet.internal.servlet.*; /** * @author Raymond Augé @@ -45,6 +50,63 @@ public class DispatchTargets { this.pathInfo = pathInfo; } + public boolean doDispatch( + HttpServletRequest request, HttpServletResponse response, + String requestURI, DispatcherType dispatcherType) + throws ServletException, IOException { + + if (dispatcherType == DispatcherType.INCLUDE) { + request.setAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH, contextController.getContextPath()); + request.setAttribute(RequestDispatcher.INCLUDE_PATH_INFO, getPathInfo()); + request.setAttribute(RequestDispatcher.INCLUDE_QUERY_STRING, request.getQueryString()); + request.setAttribute(RequestDispatcher.INCLUDE_REQUEST_URI, requestURI); + request.setAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH, getServletPath()); + } + else if (dispatcherType == DispatcherType.FORWARD) { + response.resetBuffer(); + + request.setAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH, request.getContextPath()); + request.setAttribute(RequestDispatcher.FORWARD_PATH_INFO, request.getPathInfo()); + request.setAttribute(RequestDispatcher.FORWARD_QUERY_STRING, request.getQueryString()); + request.setAttribute(RequestDispatcher.FORWARD_REQUEST_URI, request.getRequestURI()); + request.setAttribute(RequestDispatcher.FORWARD_SERVLET_PATH, request.getServletPath()); + } + + HttpServletRequestBuilder httpRuntimeRequest = HttpServletRequestBuilder.findHttpRuntimeRequest(request); + boolean pushedState = false; + + try { + if (httpRuntimeRequest == null) { + httpRuntimeRequest = new HttpServletRequestBuilder(request, this, dispatcherType); + request = httpRuntimeRequest; + response = new HttpServletResponseWrapperImpl(response); + } + else { + httpRuntimeRequest.push(this); + pushedState = true; + } + + ResponseStateHandler responseStateHandler = new ResponseStateHandler( + request, response, this, dispatcherType); + + responseStateHandler.processRequest(); + + if ((dispatcherType == DispatcherType.FORWARD) && + !response.isCommitted()) { + + response.flushBuffer(); + response.getWriter().close(); + } + + return true; + } + finally { + if (pushedState) { + httpRuntimeRequest.pop(); + } + } + } + public ContextController getContextController() { return contextController; } |