Issue #9643 fix getRequestURL for forwards (#9644)

This commit is contained in:
Jan Bartel 2023-04-14 00:10:56 +10:00 committed by GitHub
parent f28784fe0d
commit d4708d96c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -259,6 +259,12 @@ public class Dispatcher implements RequestDispatcher
return _uri == null ? super.getRequestURI() : _uri.getPath();
}
@Override
public StringBuffer getRequestURL()
{
return _uri == null ? super.getRequestURL() : new StringBuffer(HttpURI.build(_uri).query(null).scheme(super.getScheme()).host(super.getServerName()).port(super.getServerPort()).asString());
}
@Override
public Object getAttribute(String name)
{

View File

@ -1238,6 +1238,7 @@ public class DispatcherTest
assertEquals("/context/AssertForwardServlet", request.getRequestURI());
assertEquals("/context", request.getContextPath());
assertEquals("/AssertForwardServlet", request.getServletPath());
assertEquals("http://local:80/context/AssertForwardServlet", request.getRequestURL().toString());
response.setContentType("text/html");
response.setStatus(HttpServletResponse.SC_OK);