Skip to content

Commit

Permalink
Issue #7858 - Better conditional logic in GzipHandler
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
joakime committed Apr 11, 2022
1 parent cbce133 commit b03f75b
Showing 1 changed file with 10 additions and 4 deletions.
Expand Up @@ -616,9 +616,6 @@ public void setInflateBufferSize(int size)
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
if (response.isCommitted() || baseRequest.isHandled())
return;

ServletContext context = baseRequest.getServletContext();
String path = context == null ? baseRequest.getRequestURI() : URIUtil.addPaths(baseRequest.getServletPath(), baseRequest.getPathInfo());
LOG.debug("{} handle {} in {}", this, baseRequest, context);
Expand All @@ -631,7 +628,7 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
}

// Handle request inflation
if (_inflateBufferSize > 0)
if (_inflateBufferSize > 0 && !baseRequest.isHandled())
{
boolean inflate = false;
for (ListIterator<HttpField> i = baseRequest.getHttpFields().listIterator(); i.hasNext(); )
Expand Down Expand Up @@ -676,6 +673,15 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
}
}

// From here on out, the response output gzip determination is made

// Don't attempt to modify the response output if it's already committed.
if (response.isCommitted())
{
_handler.handle(target, baseRequest, request, response);
return;
}

// Are we already being gzipped?
HttpOutput out = baseRequest.getResponse().getHttpOutput();
HttpOutput.Interceptor interceptor = out.getInterceptor();
Expand Down

0 comments on commit b03f75b

Please sign in to comment.