Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
http-2.2.0
-
None
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.