#74 √ resolved
Dan Kubb

Content-Length should be added when possible

Reported by Dan Kubb | July 18th, 2008 @ 03:39 PM | in Future

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.

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket