Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Content-Length should be added when possible

#74

Right now, if the Content-Length isn't provided to Thin, it will pass the request through to the client as-is.

In my case Merb does not automatically add the Content-Length when using HAML (although this could affect ERB and other templating systems, I haven't checked).

If the body were a String or an Array, it would be relatively inexpensive to calculate the Content-Length and include it in the response. This would help in situations where the client has requested keep-alive, but the framework doesn't set Content-Length.

In certain cases, the Content-Length should not be automatically added:

  • When the Status code is 1xx, 204 or 304
  • When the Transfer-Encoding header is set to chunked
  • When the body is neither a String or an Array

Also, I'm not entirely sure about this, but perhaps the Rack guys should be asked to include a test in Rack::Lint to ensure the Content-Length is set by the framework unless one of the above conditions is met.

Reported by Dan Kubb (dkubb) · July 18th, 2008 @ 03:39 PM

State: resolved
Milestone: Future
Assigned to: macournoyer macournoyer

Activity

  1. Dan Kubb (dkubb)
    Dan Kubb (dkubb)

    I just sent a pull request to macournoyer for the following commit on my fork (dkubb/thin):

    http://github.com/dkubb/thin/com...

    July 18th, 2008 @ 03:51 PM

  2. macournoyer
    macournoyer
    • State changed from new to resolved

    (from [affccc93679a419c8fca2f92fc11e006687bdf15]) Add Content-Length header to response automatically when possible [#74 state:resolved]

    http://github.com/macournoyer/th...

    July 19th, 2008 @ 10:13 AM

  3. Dan Kubb (dkubb)
    Dan Kubb (dkubb)

    @macournoyer: As a side note, do you think Rack::Lint should be updated to ensure the framework either sets Content-Length or Transfer-Encoding: chunked on its own? I think perhaps that should be the case, but I wanted to see what you thought.

    July 19th, 2008 @ 11:26 AM

  4. macournoyer
    macournoyer

    Yeah I think that should be the responsibility of the framework to set Content-Length. Since the framework built the response, it knows better how to compute de length.

    So yeah, I agree that Lint should validate that the app sets it.

    July 19th, 2008 @ 04:23 PM

  5. John
    John

    Ludzie starają się, aby Bardzo trudno jest znaleźć renomowane i rzetelne kasyno internetowe. Jeśli spojrzysz na kasyno VulkanBet, będziesz pewien, że jest to coś, co może pomóc ci przestać wykonywać pracę, której nienawidzisz, Nie mogłem uwierzyć, że mogę zarabiać pieniądze z zabawy. Poza tym to niesamowite, że nie muszę pracować cały dzień, żeby mieć wystarczająco dużo https://vulkan-bet.me/ pieniędzy.

    January 16th, 2024 @ 07:37 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.