Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
janbartel committed Feb 27, 2024
1 parent e87f80d commit 66cb5d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class CrossContextDispatcher implements RequestDispatcher
public static final String ORIGINAL_SERVLET_MAPPING = "org.eclipse.jetty.dispatch.originalServletMapping";
public static final String ORIGINAL_SERVLET_CONTEXT = "org.eclipse.jetty.dispatch.originalServletContext";
public static final String ORIGINAL_CONTEXT_PATH = "org.eclipse.jetty.dispatch.originalContextPath";
public static final String ORIGINAL_PARAMS = "org.eclipse.jetty.dispatch.originalParameters";

public static final Set<String> ATTRIBUTES = Set.of(
RequestDispatcher.FORWARD_REQUEST_URI,
Expand All @@ -63,8 +62,7 @@ class CrossContextDispatcher implements RequestDispatcher
ORIGINAL_PATH_INFO,
ORIGINAL_SERVLET_PATH,
ORIGINAL_SERVLET_CONTEXT,
ORIGINAL_CONTEXT_PATH,
ORIGINAL_PARAMS
ORIGINAL_CONTEXT_PATH
);

private final CrossContextServletContext _targetContext;
Expand Down Expand Up @@ -115,7 +113,6 @@ protected Set<String> getSyntheticNameSet()
setAttribute(ORIGINAL_SERVLET_MAPPING, getServletRequest().getHttpServletMapping());
setAttribute(ORIGINAL_SERVLET_CONTEXT, getServletRequest().getServletContext());
setAttribute(ORIGINAL_CONTEXT_PATH, getServletRequest().getContextPath());
setAttribute(ORIGINAL_PARAMS, getServletRequest().getParameterMap());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ protected Object getSyntheticAttribute(String name)
if (name == null)
return null;

//Servlet Spec 9.3.1 no include attributes if a named dispatcher
/* if (_namedServlet != null && name.startsWith(Dispatcher.__INCLUDE_PREFIX))
return null;*/

//Special include attributes refer to the target context and path
return switch (name)
{
Expand Down Expand Up @@ -134,9 +130,6 @@ public IncludeResponse(ServletCoreRequest servletCoreRequest, HttpServletRespons

private class ForwardRequest extends ServletCoreRequest
{
/**
* @param httpServletRequest the request to wrap
*/
public ForwardRequest(ContextHandler.CoreContextRequest coreContextRequest, HttpServletRequest httpServletRequest)
{
super(coreContextRequest, httpServletRequest, new Attributes.Synthetic(new ServletAttributes(httpServletRequest))
Expand Down Expand Up @@ -241,11 +234,19 @@ public void include(ServletRequest servletRequest, ServletResponse servletRespon
{
HttpServletRequest httpServletRequest = (servletRequest instanceof HttpServletRequest) ? ((HttpServletRequest)servletRequest) : new ServletRequestHttpWrapper(servletRequest);
HttpServletResponse httpServletResponse = (servletResponse instanceof HttpServletResponse) ? (HttpServletResponse)servletResponse : new ServletResponseHttpWrapper(servletResponse);

Request baseRequest = Objects.requireNonNull(Request.getBaseRequest(servletRequest));
Response baseResponse = baseRequest.getResponse();

ContextHandler.CoreContextRequest coreContextRequest = baseRequest.getCoreRequest();
org.eclipse.jetty.server.Response coreResponse = coreContextRequest.getHttpChannel().getCoreResponse();

// TODO ServletContextResponse servletContextResponse = ServletContextResponse.getServletContextResponse(servletResponse);
/*
IncludeRequest includeRequest = new IncludeRequest(httpServletRequest);
IncludeResponse includeResponse = new IncludeResponse(includeRequest, httpServletResponse);

IncludeRequest includeRequest = new IncludeRequest(coreContextRequest, httpServletRequest);
//IncludeResponse includeResponse = new IncludeResponse(includeRequest, httpServletResponse);

/*
try (Blocker.Callback callback = Blocker.callback())
{
_targetContext.getTargetContext().getContextHandler().handle(includeRequest, includeResponse, callback);
Expand Down

0 comments on commit 66cb5d5

Please sign in to comment.