https://issues.apache.org/bugzilla/show_bug.cgi?id=49591
Summary: Custom error page always uses Transfer-Encoding: chunked Product: Tomcat 7 Version: 7.0.0 Platform: PC OS/Version: Windows XP Status: NEW Severity: enhancement Priority: P2 Component: Catalina AssignedTo: dev@tomcat.apache.org ReportedBy: km...@autonomy.com Created an attachment (id=25759) --> (https://issues.apache.org/bugzilla/attachment.cgi?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 follows: 1. I added these lines to webapps/ROOT/WEB-INF/web.xml: <error-page> <error-code>404</error-code> <location>/404.jsp</location> </error-page> 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 { response.flushBuffer(); } 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: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org