Brad Gessler
2008-Aug-01 02:22 UTC
parse_formatted_request_parameters does not respect parameters[:format]
I have been working on a project where I need to parse various flavors of XML that are POSTed from various SMS message aggregators into request_parameters. I tried to take advantage of the built in ActionController::Base.param_parsers but ran into some serious problems. Since I can''t control the aggregators'' HTTP Content-Type headers to resolve the Mime::Type, I need to rely on the '':format'' idiom in Rails routes. So instead of an HTTP POST to ''/sms_messages.xml'' I POST to ''/ sms_messages.clickatell''. Unfortunately the format parameter isn''t parsed out of the request until after the param_parser is selected: http://github.com/rails/rails/tree/master/actionpack/lib/action_controller/request.rb#L414 It appears that the content_type variable can only resolved from the Content-Type header at this point and not from params[:format] (or any other parameters for this matter). I need rails to respect the format of the request over the Content-Type header on a POST or PUT. I want to fix this but I''m not sure where to start (I get stuck in the recognize_path code... go figure). Any suggestions or help would be greatly appreciated to get me heading down the right path. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Koziarski
2008-Aug-02 08:40 UTC
Re: parse_formatted_request_parameters does not respect parameters[:format]
On Fri, Aug 1, 2008 at 4:22 AM, Brad Gessler <bradgessler@gmail.com> wrote:> > I have been working on a project where I need to parse various flavors > of XML that are POSTed from various SMS message aggregators into > request_parameters. I tried to take advantage of the built in > ActionController::Base.param_parsers but ran into some serious > problems. > > Since I can''t control the aggregators'' HTTP Content-Type headers to > resolve the Mime::Type, I need to rely on the '':format'' idiom in Rails > routes. So instead of an HTTP POST to ''/sms_messages.xml'' I POST to ''/ > sms_messages.clickatell''. Unfortunately the format parameter isn''t > parsed out of the request until after the param_parser is selected: > > http://github.com/rails/rails/tree/master/actionpack/lib/action_controller/request.rb#L414 > > It appears that the content_type variable can only resolved from the > Content-Type header at this point and not from params[:format] (or any > other parameters for this matter). I need rails to respect the format > of the request over the Content-Type header on a POST or PUT. > > I want to fix this but I''m not sure where to start (I get stuck in the > recognize_path code... go figure). Any suggestions or help would be > greatly appreciated to get me heading down the right path.We can''t really make the parameter parser depend on params[:format] because we can''t figure it out until after we''ve parsed the parameters already. We could make an exception for the case where the route overrides params[:format] but that doesn''t seem particularly tidy. More fundamentally though, the format in params[:format] is the *response* format, and the parsers are the request format. Seems a mistake to couple those two together.> > >-- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---