According to the spec, Content-Length is *not* required. It is only required to be correct if it is present. Part of the reason for this is that repeatedly calculating Content-Length is quite expensive compared to a single outbound server (like Passenger itself) calculating it before sending it on.

-- Yehuda

On Sun, Jun 28, 2009 at 5:56 PM, Joe Fiorini <joe@faithfulgeek.org> wrote:

I'm at the starting phase of building a web app using Rack. I'm trying
to add in some useful middleware on top of the Lobster demo. I want to
ensure my app always matches the spec, so I'm using Rack::Lint.
However, this immediately bombs out telling me the Content-Length is
nil. My config.ru looks like this:

require 'rack'
require 'rack/lobster'

use Rack::ShowExceptions
use Rack::CommonLogger
use Rack::ShowStatus
use Rack::Lint
use Rack::ContentLength
run Rack::Lobster.new


But even if I take it down to this:

require 'rack'
require 'rack/lobster'

use Rack::Lint
use Rack::ContentLength
run Rack::Lobster.new

it still breaks! I'm running the app on Passenger. It does work,
however, if I run straight through the rackup executable. Perhaps
Passenger is mangling my env hash? If I take out Rack::Lint and run it
(via Passenger), the headers do show a valid Content-Length. Weird,
eh?

Perplexed,
Joe



--
Yehuda Katz
Developer | Engine Yard
(ph) 718.877.1325