Skip to content

Commit

Permalink
Issue #1618 Async dispatch encoded passed URI
Browse files Browse the repository at this point in the history
  • Loading branch information
gregw authored and joakime committed Aug 8, 2017
1 parent b81115d commit c9a1395
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Expand Up @@ -2258,7 +2258,15 @@ public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse se
_async=new AsyncContextState(state);
AsyncContextEvent event = new AsyncContextEvent(_context,_async,state,this,servletRequest,servletResponse);
event.setDispatchContext(getServletContext());
event.setDispatchPath(URIUtil.encodePath(URIUtil.addPaths(getServletPath(),getPathInfo())));

String uri = ((HttpServletRequest)servletRequest).getRequestURI();
if (uri.startsWith(_contextPath))
uri = uri.substring(_contextPath.length());
else
// TODO probably need to strip encoded context from requestURI, but will do this for now:
uri = URIUtil.encodePath(URIUtil.addPaths(getServletPath(),getPathInfo()));

event.setDispatchPath(uri);
state.startAsync(event);
return _async;
}
Expand Down
Expand Up @@ -261,7 +261,6 @@ public void testDispatchAsyncContext_EncodedUrl() throws Exception
}

@Test
@Ignore("See https://github.com/eclipse/jetty.project/issues/1618")
public void testDispatchAsyncContext_SelfEncodedUrl() throws Exception
{
String request = "GET /ctx/self/hello%2fthere?dispatch=true HTTP/1.1\r\n" +
Expand All @@ -274,8 +273,8 @@ public void testDispatchAsyncContext_SelfEncodedUrl() throws Exception

String responseBody = response.getContent();

assertThat("servlet request uri initial", responseBody, containsString("doGet:REQUEST.requestURI:/ctx/self/hello%2fthere"));
assertThat("servlet request uri async", responseBody, containsString("doGet:ASYNC.requestURI:/ctx/self/hello%2fthere"));
assertThat("servlet request uri initial", responseBody, containsString("doGet.REQUEST.requestURI:/ctx/self/hello%2fthere"));
assertThat("servlet request uri async", responseBody, containsString("doGet.ASYNC.requestURI:/ctx/self/hello%2fthere"));
}

@Test
Expand Down Expand Up @@ -353,7 +352,6 @@ public void testDispatch() throws Exception
"\r\n";

String responseString = _connector.getResponse(request);
System.err.println(responseString);
HttpTester.Response response = HttpTester.parseResponse(responseString);
assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_OK));

Expand Down

0 comments on commit c9a1395

Please sign in to comment.