This project is archived and is in readonly mode.

#2295 ✓stale
Chris Heald

Setting non-string header values causes Rack errors

Reported by Chris Heald | March 19th, 2009 @ 12:15 AM | in 3.x

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"
  def fail
    headers["Expires"] = ( + 10.minutes)
    render :text => "ok"

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.

Comments and changes to this ticket

  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:50 PM

    • 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.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:50 PM

    • State changed from “open” to “stale”

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket