Issue #1618 Async dispatch encoded passed URI

This commit is contained in:
Greg Wilkins 2017-06-21 10:28:26 +02:00
parent de976e8777
commit 90e5b5603b
2 changed files with 11 additions and 5 deletions

View File

@ -2258,7 +2258,15 @@ public class Request implements HttpServletRequest
_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;
}

View File

@ -261,7 +261,6 @@ public class AsyncContextTest
}
@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" +
@ -274,8 +273,8 @@ public class AsyncContextTest
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
@ -353,7 +352,6 @@ public class AsyncContextTest
"\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));