Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetty 12.0.x 10582 servlethttpwrapper #10587

Merged
merged 6 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,188 +43,186 @@ public ServletRequestHttpWrapper(ServletRequest request)
@Override
public String getAuthType()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public Cookie[] getCookies()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public long getDateHeader(String name)
{
return 0;
throw new UnsupportedOperationException();
}

@Override
public String getHeader(String name)
{
return null;
throw new UnsupportedOperationException();
}

@Override
public Enumeration<String> getHeaders(String name)
public Enumeration<String> getHeaderNames()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public Enumeration<String> getHeaderNames()
public Enumeration<String> getHeaders(String name)
{
return null;
throw new UnsupportedOperationException();
}

@Override
public int getIntHeader(String name)
{
return 0;
throw new UnsupportedOperationException();
}

@Override
public String getMethod()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public String getPathInfo()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public String getPathTranslated()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public String getContextPath()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public String getQueryString()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public String getRemoteUser()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public boolean isUserInRole(String role)
{
return false;
throw new UnsupportedOperationException();
}

@Override
public Principal getUserPrincipal()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public String getRequestedSessionId()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public String getRequestURI()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public StringBuffer getRequestURL()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public String getServletPath()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public HttpSession getSession(boolean create)
{
return null;
throw new UnsupportedOperationException();
}

@Override
public HttpSession getSession()
{
return null;
throw new UnsupportedOperationException();
}

@Override
public boolean isRequestedSessionIdValid()
{
return false;
throw new UnsupportedOperationException();
}

@Override
public boolean isRequestedSessionIdFromCookie()
{
return false;
throw new UnsupportedOperationException();
}

@Override
public boolean isRequestedSessionIdFromURL()
{
return false;
throw new UnsupportedOperationException();
}

@Override
public boolean authenticate(HttpServletResponse response) throws IOException, ServletException
{
return false;
throw new UnsupportedOperationException();
}

@Override
public Part getPart(String name) throws IOException, ServletException
{
return null;
throw new UnsupportedOperationException();
}

@Override
public Collection<Part> getParts() throws IOException, ServletException
{
return null;
throw new UnsupportedOperationException();
}

@Override
public void login(String username, String password) throws ServletException
{

throw new UnsupportedOperationException();
}

@Override
public void logout() throws ServletException
{

throw new UnsupportedOperationException();
}

@Override
public String changeSessionId()
{
// TODO 3.1 Auto-generated method stub
return null;
throw new UnsupportedOperationException();
}

@Override
public <T extends HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IOException, ServletException
{
// TODO 3.1 Auto-generated method stub
return null;
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,66 @@ public void testInclude() throws Exception
assertEquals(expected, responses);
}

@Test
public void testServletIncludeWelcome() throws Exception
{
_server.stop();
_contextHandler.setWelcomeFiles(new String[] {"index.x"});
_contextHandler.addServlet(DispatchServletServlet.class, "/dispatch/*");
ServletHolder defaultHolder = _contextHandler.addServlet(DefaultServlet.class, "/");
defaultHolder.setInitParameter("welcomeServlets", "true");
_contextHandler.addServlet(RogerThatServlet.class, "*.x");
_server.start();

String rawResponse = _connector.getResponse("""
GET /context/r/ HTTP/1.0\r
Host: localhost\r
Connection: close\r
\r
""");

String expected = """
HTTP/1.1 200 OK\r
Content-Length: 11\r
\r
Roger That!""";

assertEquals(expected, rawResponse);


// direct include
rawResponse = _connector.getResponse("""
GET /context/dispatch/test?include=/index.x HTTP/1.0\r
Host: localhost\r
Connection: close\r
\r
""");

expected = """
HTTP/1.1 200 OK\r
Content-Length: 11\r
\r
Roger That!""";

assertEquals(expected, rawResponse);

// include through welcome file based on servlet mapping
rawResponse = _connector.getResponse("""
GET /context/dispatch/test?include=/r/ HTTP/1.0\r
Host: localhost\r
Connection: close\r
\r
""");

expected = """
HTTP/1.1 200 OK\r
Content-Length: 11\r
\r
Roger That!""";

assertEquals(expected, rawResponse);
}

public static Stream<Arguments> includeTests()
{
return Stream.of(
Expand Down Expand Up @@ -1142,13 +1202,13 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
if (request.getParameter("include") != null)
{
dispatcher = getServletContext().getRequestDispatcher(request.getParameter("include"));
dispatcher.include(new ServletRequestWrapper(request), new ServletResponseWrapper(response));
dispatcher.include(new HttpServletRequestWrapper(request), new HttpServletResponseWrapper(response));
}
else if (request.getParameter("forward") != null)
{
dispatcher = getServletContext().getRequestDispatcher(request.getParameter("forward"));
if (dispatcher != null)
dispatcher.forward(new ServletRequestWrapper(request), new ServletResponseWrapper(response));
dispatcher.forward(new HttpServletRequestWrapper(request), new HttpServletResponseWrapper(response));
else
response.sendError(404);
}
Expand Down
Loading