Hello I''ve a client which send this request to a mongrel HTTPHandler : res=Net::HTTP.post_form(URI.parse(''http://localhost:3000/test''),{"a"=>1,"b"=>2}) But in the handler I can''t read the parameters one by one, I can read the entire String only : class Serveur class MyHandler < Mongrel::HttpHandler def process(req, resp) ... @params=req.params @params.http_body ... end end ... end @params.http_body give me : a=1&b=2 which is a string I would like a code which return me 1 for something[:a] and 2 for something[:b]... thanks -- Posted via http://www.ruby-forum.com/.
HttpRequest.query_parse(@params.http_body) http://mongrel.rubyforge.org/rdoc/classes/Mongrel/HttpRequest.html#M000126 On Jan 14, 2008 6:12 PM, Abir B. <lists at ruby-forum.com> wrote:> Hello > I''ve a client which send this request to a mongrel HTTPHandler : > > res=Net::HTTP.post_form(URI.parse(''http://localhost:3000/test''),{"a"=>1,"b"=>2}) > > But in the handler I can''t read the parameters one by one, I can read > the entire String only : > class Serveur > class MyHandler < Mongrel::HttpHandler > def process(req, resp) > ... > @params=req.params > @params.http_body > ... > end > end > ... > end > > > @params.http_body give me : > a=1&b=2 which is a string > > I would like a code which return me 1 for something[:a] and 2 for > something[:b]... > thanks > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >
Eden Li wrote:> HttpRequest.query_parse(@params.http_body) > > http://mongrel.rubyforge.org/rdoc/classes/Mongrel/HttpRequest.html#M000126:-) that''s just what I''m searching (I tried it with a wrong syntax : req.query_parse and it didn''t work...) thanks -- Posted via http://www.ruby-forum.com/.
On Mon, 14 Jan 2008 15:39:25 +0100 "Abir B." <lists at ruby-forum.com> wrote:> Eden Li wrote: > > HttpRequest.query_parse(@params.http_body) > > > > http://mongrel.rubyforge.org/rdoc/classes/Mongrel/HttpRequest.html#M000126 > > :-) > that''s just what I''m searching (I tried it with a wrong syntax : > req.query_parse and it didn''t work...)Yes, sadly you have to do this yourself because all the frameworks have their own interpretation of how the query parameters are parsed. -- Zed A. Shaw - Hate: http://savingtheinternetwithhate.com/ - Good: http://www.zedshaw.com/ - Evil: http://yearofevil.com/