https://bz.apache.org/bugzilla/show_bug.cgi?id=61217

            Bug ID: 61217
           Summary: Tomcat dose not send all buffer in case of response
                    was modify
           Product: Tomcat 8
           Version: 8.0.33
          Hardware: Macintosh
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: tzachi.str...@behalf.com
  Target Milestone: ----

IdentityOutputFilter not write all bytes in case the response was increased in
servlet filter

scenario:
1. Add filter servlet that changed the content of the response(increase the
size).
2. add controller that create response with header content-type

Example:
  originalResponse message - 'Example of response to request-1'
  modify response - 'Example of response to cmVxdWVzdC0x' 

the size of original is 33 
the size of the modify is 36

The response of the servlet will be only 33 chars from the modify response: 
'Example of response to cmVxdWVzd'

The reason is that response initialize IdentityOutputFilter with content length
of the original.
the doWrite method get byte chunk but it remove the bytes that bigger than 
in case response contains Content-Length header the IdentityOutputFilter will
try to write buffer. 

 if (result > remaining) {
                    // The chunk is longer than the number of bytes remaining
                    // in the body; changing the chunk length to the number
                    // of bytes remaining
                    chunk.setBytes(chunk.getBytes(), chunk.getStart(),
                                   (int) remaining);
                    result = (int) remaining;
                    remaining = 0;
                }

-- 
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

Reply via email to