Override Rack::Request#media_type instead of #content_type#16018
Override Rack::Request#media_type instead of #content_type#16018rafaelfranca wants to merge 1 commit intorails:masterfrom
Conversation
|
Ah, before this change: |
Rack::Request#content_type is used by a lot of Rack::Request methods like #media_type_params and #content_charset. All these methods expect #content_type to be the full env['CONTENT_TYPE'] header. Since we are overriding #content_type to return only the Mime::Type.to_s these methods stop to work since no information about media type parameters are returned on #content_type.
|
👍 |
1 similar comment
|
👍 |
|
Agreed in theory, but deprecation is impossible for a return-value behavior change like this. It'll cause many subtle bugs in engines, apps, etc. May be better to find a new way forward, like providing a |
|
Not sure if it is worth to patch the Maybe in Rails 5 we can merge this patch as it is? |
|
Giving up |
Rack::Request#content_typeis used by a lot ofRack::Requestmethods like#media_type_paramsand#content_charset. All these methods expect#content_typeto be the fullenv['CONTENT_TYPE']header.Since we are overriding
#content_typeto return only theMime::Type.to_sthese methods stop to work since no information about media type parameters are returned on#content_type.These is a subtle change of behaviour here since
#content_typewill return more information than before so I'm not sure we should apply this patch without a proper deprecation path pointing people to usemedia_typewhen expecting only the media type.@jeremy @tenderlove let me know what you think about this change of behaviour.