Martin Sarsale
2008-Jul-10 15:51 UTC
[Mechanize-users] custom http headers in form.submit / upload without original form
Heyas :) I''m wondering how do I do to send my custom HTTP headers when posting a form. agent.set_headers is a private method and I don''t know how to get a reference to HTTPHeaders to use add_field and such. Since my request is a form, I''m sending it using agent.submit(form). Any hints? Bonus question: I would like to upload a file to a REST webservice, but I haven''t found the way to do it without first creating a Hpricot form node which IMHO doesn''t makes much sense :) thanks in advance! -- Martin Sarsale - martin at malditainternet.com
Mat Schaffer
2008-Jul-11 04:33 UTC
[Mechanize-users] custom http headers in form.submit / upload without original form
The most recent version of mechanize should support this by just putting a File object in your post parameters. See: http://github.com/schapht/mechaflickr/tree/master/lib/mechaflickr.rb#L75 For an example. -Mat On Jul 10, 2008, at 11:51 AM, Martin Sarsale wrote:> Heyas :) > > I''m wondering how do I do to send my custom HTTP headers when posting > a form. agent.set_headers is a private method and I don''t know how to > get a reference to HTTPHeaders to use add_field and such. > Since my request is a form, I''m sending it using agent.submit(form). > Any hints? > > Bonus question: I would like to upload a file to a REST webservice, > but I haven''t found the way to do it without first creating a Hpricot > form node which IMHO doesn''t makes much sense :) > > thanks in advance! > > -- > Martin Sarsale - martin at malditainternet.com > _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mechanize-users