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

Implemented servlet 6.1 redirect with content #11743

Merged
merged 15 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -144,7 +144,7 @@ public HttpURI getHttpURI()
}
}

private class IncludeResponse extends ServletCoreResponse
private static class IncludeResponse extends ServletCoreResponse
{
public IncludeResponse(Request coreRequest, HttpServletResponse httpServletResponse)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,24 @@ public void sendRedirect(String location) throws IOException
{
// NOOP for include.
}

@Override
public void sendRedirect(String location, boolean clearBuffer) throws IOException
{
// NOOP for include.
}

@Override
public void sendRedirect(String location, int sc) throws IOException
{
// NOOP for include.
}

@Override
public void sendRedirect(String location, int sc, boolean clearBuffer) throws IOException
{
// NOOP for include.
}
}

private class AsyncRequest extends ParameterRequestWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,4 +656,132 @@ public String toString()
return HttpCookie.toString(this);
}
}

public static class CrossContextInclude extends ServletApiResponse
{
public CrossContextInclude(ServletContextResponse servletContextResponse)
{
super(servletContextResponse);
}

@Override
public void setCharacterEncoding(String charset)
{
// NOOP for include.
}

@Override
public void setLocale(Locale loc)
{
// NOOP for include.
}

@Override
public void setContentLength(int len)
{
// NOOP for include.
}

@Override
public void setContentLengthLong(long len)
{
// NOOP for include.
}

@Override
public void setContentType(String type)
{
// NOOP for include.
}

@Override
public void reset()
{
// NOOP for include.
}

@Override
public void resetBuffer()
{
// NOOP for include.
}

@Override
public void setDateHeader(String name, long date)
{
// NOOP for include.
}

@Override
public void addDateHeader(String name, long date)
{
// NOOP for include.
}

@Override
public void setHeader(String name, String value)
{
// NOOP for include.
}

@Override
public void addHeader(String name, String value)
{
// NOOP for include.
}

@Override
public void setIntHeader(String name, int value)
{
// NOOP for include.
}

@Override
public void addIntHeader(String name, int value)
{
// NOOP for include.
}

@Override
public void setStatus(int sc)
{
// NOOP for include.
}

@Override
public void sendError(int sc, String msg) throws IOException
{
// NOOP for include.
}

@Override
public void sendError(int sc) throws IOException
{
// NOOP for include.
}

@Override
public void sendRedirect(String location) throws IOException
{
// NOOP for include.
}

@Override
public void sendRedirect(String location, boolean clearBuffer) throws IOException
{
// NOOP for include.
}

@Override
public void sendRedirect(String location, int sc) throws IOException
{
// NOOP for include.
}

@Override
public void sendRedirect(String location, int sc, boolean clearBuffer) throws IOException
{
// NOOP for include.
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Map;
import java.util.function.Supplier;

import jakarta.servlet.DispatcherType;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.ServletResponseWrapper;
Expand Down Expand Up @@ -174,6 +175,9 @@ protected ServletContextRequest getServletContextRequest()

protected ServletApiResponse newServletApiResponse()
{
if (_servletChannel.getServletContextHandler().isCrossContextDispatchSupported() &&
DispatcherType.INCLUDE.toString().equals(_servletChannel.getRequest().getContext().getCrossContextDispatchType(_servletChannel.getRequest())))
return new ServletApiResponse.CrossContextInclude(this);
return new ServletApiResponse(this);
}

Expand Down
Loading