This project is archived and is in readonly mode.
AC::Request#content_type should return a string
Reported by Michael Schuerig | April 25th, 2009 @ 07:37 PM | in 2.x
Today, I git pulled rails 2-3-stable and (inadvertently) updated rack to 1.0.0, therefore I can definitely tell who's at fault, it might even be me. Anyway, Rack::Request#media_type expects #content_type to return a string which it may not always do in its current incarnation. Below I've added in the tiny #to_s
ActionController::Request < Rack::Request
def content_type
@content_type ||= begin
if @env['CONTENT_TYPE'] =~ /^([^,\;]*)/
Mime::Type.lookup($1.strip.downcase).to_s
else
nil
end
end
end
This issue may affect other code at the intersection of ActionController and Rack. ActionController uses Mime::Type objects freely, but Rack doesn't know about them.
Comments and changes to this ticket
-
Michael Schuerig April 25th, 2009 @ 09:52 PM
I just found out that the solution isn't that easy. It just blows up in another place, namely in request verification where it is assumed that request.content_type is a Mime::Type
def verifiable_request_format? !request.content_type.nil? && request.content_type.verify_request? end
The easiest solution would be to have Rack call #to_s on whatever it gets from Rack::Request#content_type.
-
CancelProfileIsBroken April 25th, 2009 @ 10:31 PM
Is this still a problem if you pull 2-3-stable now? Bundled rack was just removed a couple of hours ago, and a few other changes to accommodate the Rack release. Just want to be sure before anyone goes digging.
-
Michael Schuerig April 25th, 2009 @ 10:49 PM
That one bows up instantly as there are still references to ActionController::RewindableInput which doesn't exist anymore.
-
CancelProfileIsBroken April 25th, 2009 @ 11:30 PM
- Assigned user set to josh
Looks like yours, Josh. Confirmed that AC is still attempting to autoload RewindableInput on 2-3-stable.
-
Hongli Lai April 26th, 2009 @ 10:15 AM
These 2 patches fix the problem. Created against the 2-3-stable branch.
-
josh April 26th, 2009 @ 05:20 PM
- State changed from new to resolved
-
Bill May 14th, 2009 @ 05:03 AM
This worked for me- modifying my code to match the patches did not .
(in initializers/mime_fix.rb) module Mime
class Type def split(*args) to_s.split(*args) end end
end
-
Jeff Kreeftmeijer November 8th, 2010 @ 08:50 AM
- Tag cleared.
- Importance changed from to Low
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>