Rack::Lint - Content-Length is nil in Passenger

29 views
Skip to first unread message

Joe Fiorini

unread,
Jun 28, 2009, 8:56:03 PM6/28/09
to Rack Development
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

Magnus Holm

unread,
Jun 29, 2009, 11:16:13 AM6/29/09
to rack-...@googlegroups.com
Try putting the ContentLength-middleware above Lint.

2009/6/29, Joe Fiorini <j...@faithfulgeek.org>:


--

//Magnus Holm

Yehuda Katz

unread,
Jun 29, 2009, 11:38:42 AM6/29/09
to rack-...@googlegroups.com
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
--
Yehuda Katz
Developer | Engine Yard
(ph) 718.877.1325

Hongli Lai

unread,
Jun 30, 2009, 6:16:56 PM6/30/09
to Rack Development
Are you using 2.2.3 or later? Several Rack compliance bugs have been
fixed in 2.2.3.
Reply all
Reply to author
Forward
0 new messages