This project is archived and is in readonly mode.
head method attempts to camelcase headers
Reported by Seth Ladd | September 15th, 2010 @ 11:05 PM | in 3.0.2
I am using Rails 3 on Ruby 1.9.2.
This call:
head 401, 'WWW-Authenticate' => Rack::OpenID.build_header(:identifier => params[:openid_identifier])
actually returns:
"{"Www-Authenticate"=>"OpenID identifier=\"https://www.google.com/accounts/o8/id\"", "Content-Type"=>"text/html; charset=utf-8", "Cache-Control"=>"no-cache"}"
Notice the "Www-Authenticate" which of course does not work with rack-openid, which is correctly looking for WWW-Authenticate.
This call:
response.headers['WWW-Authenticate'] = Rack::OpenID.build_header(:identifier => params[:openid_identifier])
head 401
correctly sets the header and does not change the case of the letters.
Comments and changes to this ticket
-
Rohit Arondekar September 18th, 2010 @ 08:28 AM
- Milestone cleared.
- State changed from new to open
- Importance changed from to Low
-
Maxim Chernyak September 18th, 2010 @ 08:53 AM
Looks like we need to avoid
capitalize
here: http://github.com/rails/rails/blob/master/actionpack/lib/action_con...capitalize
not only upcases first letter, but also downcases the rest of them. Making a patch to avoidcapitalize
. -
Rohit Arondekar September 18th, 2010 @ 08:57 AM
- Assigned user set to José Valim
-
Maxim Chernyak September 18th, 2010 @ 09:15 AM
- Tag changed from rails 3.0.0 to rails 3.0.0, patch
Here's patch + test against master.
-
José Valim September 18th, 2010 @ 07:20 PM
Looks good, but couldn't we do something like this instead:
headers[key.to_s.dasherize.split("-").each { |v| v[0] = v[0].upcase }.join("-")] = value.to_s
Seems faster and simpler!
-
Maxim Chernyak September 18th, 2010 @ 07:25 PM
@Jose
Almost right.
v[0] = v[0].chr.upcase
. Will fix now, sec. -
José Valim September 18th, 2010 @ 07:32 PM
One question. Why do we need .chr? It worked fine without it on 1.8.7 and 1.9.2.
-
Maxim Chernyak September 18th, 2010 @ 07:35 PM
Strange.
ruby-1.8.7-p302 > v = 'foo' => "foo" ruby-1.8.7-p302 > v[0] = v[0].upcase NoMethodError: undefined method `upcase' for 102:Fixnum from (irb):2
-
Maxim Chernyak September 18th, 2010 @ 07:39 PM
Happens. :) I don't know why I didn't do first char assignment in the first place, thanks.
Here's the new patch.
-
Repository September 18th, 2010 @ 07:50 PM
- State changed from open to resolved
(from [20685d07ab5853457e1d11467f22ed42568e20f4]) Fix header capitalization by explicitly upcasing first letter of every word, and avoiding capitalize. [#5636 state:resolved] http://github.com/rails/rails/commit/20685d07ab5853457e1d11467f22ed...
-
Ryan Bigg October 16th, 2010 @ 02:22 AM
- Tag changed from rails 3.0.0, sheepskin boots, patch to patch rails 3.0.0
Automatic cleanup of spam.
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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 5636 head method attempts to camelcase headers (from [20685d07ab5853457e1d11467f22ed42568e20f4]) Fix hea...