version 0.62 I''ve got a form that''s giving me trouble (server reports invalid session ID). Unfortunately, the form is submitted using SSL so I can''t use a sniffer to see the differences between the ruby mechanize version and the perl mechanize version that is working. Is there a way to change the form action within mechanize? Or a way to display the request headers? Thanks, Jon
Hey Jon, On Tue, Oct 17, 2006 at 10:14:23AM -0700, Rust, Jon wrote:> version 0.62 > > I''ve got a form that''s giving me trouble (server reports invalid session > ID). Unfortunately, the form is submitted using SSL so I can''t use a > sniffer to see the differences between the ruby mechanize version and > the perl mechanize version that is working. Is there a way to change the > form action within mechanize? Or a way to display the request headers?If you set mechanize to log, it should log your request headers. So just do this: require ''logger'' agent = WWW::Mechanize.new { |a| a.log = Logger.new(''mech.log'') } You can also change the action on the form. There is an action= method on the form, so you could just do this: form.action = ''/some_location'' I can help more if it is possible for you to send a sample script that breaks.> > Thanks, > Jon > _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mechanize-users-- Aaron Patterson http://tenderlovemaking.com/
Aaron Patterson wrote:> If you set mechanize to log, it should log your request headers. So > just do this: > require ''logger'' > agent = WWW::Mechanize.new { |a| a.log = Logger.new(''mech.log'') } > > You can also change the action on the form. There is an action= method > on the form, so you could just do this: > form.action = ''/some_location'' >Awesome! Thanks Aaron. Great s/w BTW. OK, I''ve grabbed a couple of sessions via logging, and also via sniffing. The only difference I''ve been able to find so far between Firefox, Perl Mech and Ruby Mech is that the POST URL is encoded when using Ruby Mech. Specifically, the ''&'' is represented as ''&'': POST /page.aspx?cID=1234&ssID=ksdb... vs POST /page.aspx?cID=1234&ssID=lpwioe... Expected? If it matters, the content of the POST does not have ''&'' encoded like this, just the URL provided in the initial POST. Thanks again! Jon
I wrote:> > Specifically, the ''&'' is represented as ''&'': > > POST /page.aspx?cID=1234&ssID=ksdb... > > vs > > POST /page.aspx?cID=1234&ssID=lpwioe... >Success! I sub''d the ''&'' with ''&'' in the action attribute and everything worked. Jon
On 10/17/06, Rust, Jon <jrust at lexus.elabor.com> wrote:> > Aaron Patterson wrote: > > If you set mechanize to log, it should log your request headers. So > > just do this: > > require ''logger'' > > agent = WWW::Mechanize.new { |a| a.log = Logger.new(''mech.log'') } > > > > You can also change the action on the form. There is an action= method > > on the form, so you could just do this: > > form.action = ''/some_location'' > > > > Awesome! Thanks Aaron. Great s/w BTW.Thanks! I''m glad you like it! OK, I''ve grabbed a couple of sessions via logging, and also via> sniffing. The only difference I''ve been able to find so far between > Firefox, Perl Mech and Ruby Mech is that the POST URL is encoded when > using Ruby Mech. Specifically, the ''&'' is represented as ''&'': > > POST /page.aspx?cID=1234&ssID=ksdb... > > vs > > POST /page.aspx?cID=1234&ssID=lpwioe... > > Expected? If it matters, the content of the POST does not have ''&'' > encoded like this, just the URL provided in the initial POST.Interesting! This is not expected, and looks like a bug. Can you view the source of the page and send me the action of the form? I think I know what is wrong, and I''ll try to reproduce it. Thanks again!> Jon > _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mechanize-users >-- Aaron Patterson http://tenderlovemaking.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mechanize-users/attachments/20061017/008b00a8/attachment.html
On 10/17/06, Rust, Jon <jrust at lexus.elabor.com> wrote:> > I wrote: > > > > Specifically, the ''&'' is represented as ''&'': > > > > POST /page.aspx?cID=1234&ssID=ksdb... > > > > vs > > > > POST /page.aspx?cID=1234&ssID=lpwioe... > > > > Success! I sub''d the ''&'' with ''&'' in the action attribute and > everything worked.Excellent. I am adding test cases code code which should fix this! Jon> _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mechanize-users >-- Aaron Patterson http://tenderlovemaking.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mechanize-users/attachments/20061017/60c7a28f/attachment.html
Aaron Patterson wrote:> > Interesting! This is not expected, and looks like a bug. Can you > view the source of the page and send me the action of the form? I > think I know what is wrong, and I''ll try to reproduce it. > >form name="Form1" method="post" action="page.aspx?cID=1234&ssID=14d..." id="Form1" I never noticed it was presented in the source with the encoding present. Jon