[ 
https://issues.apache.org/jira/browse/FELIX-3987?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kaspar von Gunten updated FELIX-3987:
-------------------------------------

    Description: 
The ResourceServlet.handle(..) implementation sets content-type and 
last-modified headers, then goes on and copies the specified resource's content 
onto the response's output stream. When it is done, it sets the content-length 
header to the # of written bytes.

This is just wrong, because all headers should be present before content is 
written. The implementation gets away with it, because most content probably 
fits into the internal buffers and content-length is set before flush/close is 
called, but with large content this will cause problems.

Suggestion: determine content-length in handle (analogous to last-modified) 
BEFORE calling copy(). I attached a suggested patch for the v2.2.0 
ResourceServlet.

  was:
The ResourceServlet.handle(..) implementation sets content-type and 
last-modified headers, then goes on and copies the specified resource's content 
onto the response's output stream. When it is done, it sets the content-length 
header to the # of written bytes.

This is just wrong, because all headers should be present before content is 
written. The implementation gets away with it, because most content probably 
fits into the internal buffers and content-length is set before flush/close is 
called, but with large content this will cause problems.

Suggestion: determine content-length in handle (analogous to last-modified) 
BEFORE calling copy(). I atta

    
> ResourceServlet sets content-length Header too late
> ---------------------------------------------------
>
>                 Key: FELIX-3987
>                 URL: https://issues.apache.org/jira/browse/FELIX-3987
>             Project: Felix
>          Issue Type: Bug
>          Components: HTTP Service
>    Affects Versions: http-2.2.0
>            Reporter: Kaspar von Gunten
>         Attachments: ResourceServlet.patch
>
>
> The ResourceServlet.handle(..) implementation sets content-type and 
> last-modified headers, then goes on and copies the specified resource's 
> content onto the response's output stream. When it is done, it sets the 
> content-length header to the # of written bytes.
> This is just wrong, because all headers should be present before content is 
> written. The implementation gets away with it, because most content probably 
> fits into the internal buffers and content-length is set before flush/close 
> is called, but with large content this will cause problems.
> Suggestion: determine content-length in handle (analogous to last-modified) 
> BEFORE calling copy(). I attached a suggested patch for the v2.2.0 
> ResourceServlet.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to