tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 49591] New: Custom error page always uses Transfer-Encoding: chunked
Date Tue, 13 Jul 2010 18:08:29 GMT

           Summary: Custom error page always uses Transfer-Encoding:
           Product: Tomcat 7
           Version: 7.0.0
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Catalina

Created an attachment (id=25759)
 --> (
Small JSP which should easily fit in the output buffer.

When using a small custom error JSP page (which easily fits in the output
buffer, and so would not usually require chunking), error responses always use
chunked encoding, while non-error responses do not.

For example, visiting a missing resource (resulting in a 404) serves the error
page as chunked, while visiting the error page directly (resulting in a 200)
serves the error page without chunking.

Static resources are always served unchunked.

I would like to request that a custom error JSP is not served chunked if it
fits entirely within the output buffer, just like a regular JSP would. While
not a bug, I like to avoid chunked encoding (and the extra flushes involved)
whenever possible.

I initially encountered this issue in 6.0.24, but verified it is still present
in 7.0.0, and the source code seems unchanged in the trunk.

To replicate this issue, I modified the ROOT webapp of a fresh 7.0.0 install as

1. I added these lines to webapps/ROOT/WEB-INF/web.xml:


2. I added the attached 404.jsp to webapps/ROOT/.

3. I visited http://localhost:8080/404 and received a chunked response.

4. I visited http://localhost:8080/404.jsp and received an unchunked response.

Stepping through the code, I discovered that the issue seems to be caused by a
flushBuffers() call in
org.apache.catalina.core.StandardHostValve.status(Request, Response). The code
looks something like this:

  if (custom(request, response, errorPage)) {
      try {
      } catch (ClientAbortException e) {
          // Ignore
      } catch (IOException e) {
          container.getLogger().warn("Exception Processing " + errorPage, e);

A normal page doesn't flush buffers until finishResponse() occurs, at which
point it can decide to set the content length or use chunked encoding. Flushing
earlier than that triggers chunked encoding (if possible).

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message