Skip to content

Commit

Permalink
Merge pull request #5075 from eclipse/jetty-10.0.x-ServletPathMapping…
Browse files Browse the repository at this point in the history
…Include

restore old ServletPathMapping even for include dispatch types
  • Loading branch information
lachlan-roberts committed Jul 28, 2020
2 parents a33b0e2 + 6364490 commit 7e4f32b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public Object getAttribute(String key)
case INCLUDE_CONTEXT_PATH:
{
ContextHandler.Context context = _baseRequest.getContext();
return context == null ? null : context.getContextHandler().getContextPathEncoded();
return context == null ? null : context.getContextHandler().getRequestContextPath();
}
case INCLUDE_QUERY_STRING:
return _query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,14 +794,7 @@ public String getContextPath()
if (context == null)
return null;

// For some reason the spec requires the context path to be encoded (unlike getServletPath).
String contextPath = context.getContextHandler().getContextPathEncoded();

// For the root context, the spec requires that the empty string is returned instead of the leading '/'
// which is included in the pathInContext
if (URIUtil.SLASH.equals(contextPath))
return "";
return contextPath;
return context.getContextHandler().getRequestContextPath();
}

/** Get the path in the context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,6 @@ public void doScope(String target, Request baseRequest, HttpServletRequest reque
// Get the base requests
final ServletPathMapping old_servlet_path_mapping = baseRequest.getServletPathMapping();

DispatcherType type = baseRequest.getDispatcherType();

ServletHolder servletHolder = null;
UserIdentity.Scope oldScope = null;

Expand Down Expand Up @@ -472,8 +470,7 @@ public void doScope(String target, Request baseRequest, HttpServletRequest reque
if (oldScope != null)
baseRequest.setUserIdentityScope(oldScope);

if (!(DispatcherType.INCLUDE.equals(type)))
baseRequest.setServletPathMapping(old_servlet_path_mapping);
baseRequest.setServletPathMapping(old_servlet_path_mapping);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -108,12 +107,13 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se

private void dumpAttrs(String tag, HttpServletRequest req, ServletOutputStream out) throws IOException
{
out.println(String.format("%s: %s='%s'", tag, RequestDispatcher.INCLUDE_CONTEXT_PATH,
req.getAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH)));
out.println(String.format("%s: %s='%s'", tag, RequestDispatcher.INCLUDE_SERVLET_PATH,
req.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH)));
out.println(String.format("%s: %s='%s'", tag, RequestDispatcher.INCLUDE_PATH_INFO,
req.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO)));
String contextPath = (String)req.getAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH);
String servletPath = (String)req.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
String pathInfo = (String)req.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO);

out.println(String.format("%s: %s='%s'", tag, RequestDispatcher.INCLUDE_CONTEXT_PATH, contextPath));
out.println(String.format("%s: %s='%s'", tag, RequestDispatcher.INCLUDE_SERVLET_PATH, servletPath));
out.println(String.format("%s: %s='%s'", tag, RequestDispatcher.INCLUDE_PATH_INFO, pathInfo));
}
}

Expand Down Expand Up @@ -221,7 +221,6 @@ private String getPotentialBody(HttpURLConnection connection)
}
}

@Disabled // TODO: complete merge of PR #5058.
@Test
public void testIncludeAttributes() throws IOException
{
Expand Down

0 comments on commit 7e4f32b

Please sign in to comment.