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.

This project is archived and is in readonly mode.

Setting non-string header values causes Rack errors

#2295

As of Rails 2.3, setting a non-string value for a header causes Rack to explode and Apache (in my case) to return 500s at my users.

The test case is simple: create a new app, and a controller something like:


class TestController < ApplicationController
  def pass
    render :text => "ok"
  end   
  def fail
    headers["Expires"] = (Time.now + 10.minutes)
    render :text => "ok"
  end
end

This produces an error like so in Apache's error_log:

[ pid=30425 file=Hooks.cpp:508 time=2009-03-18 16:56:47.412 ]:
  Backend process 30511 did not return a valid HTTP response. It returned: [Content-Length]
*** Exception NoMethodError in application (undefined method 'each' for Wed Mar 18 17:06:47 -0700 2009:Time) (process 30511):
        from /opt/ruby-enterprise-1.8.6-20081215/lib/ruby/gems/1.8/gems/passenger-2.1.1/lib/phusion_passenger/rack/request_handler.rb:73:in 'process_request'

The correct fix to this is likely a fix to Rack, to cast header values to strings, but Rails can patch this by casting values to strings (or enforcing that they be passed as strings) on assignment. I don't have a patch for it at the moment, though, I'm afraid.

Reported by Chris Heald · March 19th, 2009 @ 12:15 AM

State: stale
Milestone: 3.x
Assigned to: nobody
Importance: none

Activity

  1. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  2. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:50 PM

  3. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:50 PM