Docunext


Wacky Rack

December 27th, 2009

I love testing different combinations of software and so its should come as no surprise that Ruby, Rack, and the plentiful middleware for it makes for plenty of testing.

Today I was testing Regdel with Unicorn, and I ran into a problem with Rack::Lint. For some reason, something was causing a Content-Length header of zero to be sent.

I thought it might have been rack-docunext-content-length, but thankfully, no, that was not the cause.

I realized that Unicorn was defaulting to a development environment and was loading the following Rack::Middleware:

  case ENV["RACK_ENV"]
  when "development"
    Rack::Builder.new do
      use Rack::CommonLogger, $stderr
      use Rack::ShowExceptions
      use Rack::Lint
      run inner_app
    end.to_app
  when "deployment"
    Rack::Builder.new do
      use Rack::CommonLogger, $stderr
      run inner_app
    end.to_app
  else
    inner_app
  end

I believe Rack::Lint was getting called before anything else. Maybe that was the cause? I'm not sure, but if I use Rack::Lint in Regdel, there are no problems, and there is not Content-Length header of zero getting sent to my client.

I'm now launching Unicorn like this:

/var/lib/gems/1.8/gems/unicorn-0.95.3/bin/unicorn --env none -l 3000
Yearly Indexes: 2003 2004 2006 2007 2008 2009 2010 2011 2012 2013 2015 2019 2020 2022