Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-3987

ResourceServlet sets content-length header too late

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • http-2.2.0
    • http-2.2.2
    • HTTP Service
    • 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.

      Attachments

        1. ResourceServlet.patch
          0.7 kB
          Kaspar von Gunten

        Activity

          People

            jajans J.W. Janssen
            kvgunten Kaspar von Gunten
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: