Mechanize: 400 Bad Request

Hello,

when trying to access a certain HTML-frame, I get:
“in `request’: Unhandled response (WWW::Mechanize::ResponseCodeError)”

and the page returns: “400 Bad Request”

  • Why?
  • How to solve this?

With browser, it works.

Thank you for any help!

Axel

axel ° friedrich ° _smail AT gmx ° de

Details
°°°°°°°
ruby 1.8.4 (2005-12-24) [i386-mswin32]
Windows 98SE

Code
°°°°
require ‘rubygems’
require ‘mechanize’

agent = WWW::Mechanize.new
page =
agent.get(“https://www.frankfurter-fondsbank.de/login/Logon.jsp”)

… login stuff…

begin
framePage = agent.click( page2.frames.text(‘nav’) ) # This works
not

framePage = agent.click( page2.frames.text(‘head’) ) # This works

rescue WWW::Mechanize::ResponseCodeError => ex
puts ex.page.body
end

page2 looks like this
°°°°°°°°°°°°°°°°°°°°°

...

Hi Axel,

On Mon, Nov 06, 2006 at 01:05:15AM +0900, Axel wrote:

Hello,

when trying to access a certain HTML-frame, I get:
“in `request’: Unhandled response (WWW::Mechanize::ResponseCodeError)”

and the page returns: “400 Bad Request”

  • Why?
  • How to solve this?

Can you turning on logging, and forward that to the mechanize mailing
list? The URL in the frame may be getting clobbered, but I can’t tell
without looking at the logs.

http://rubyforge.org/mail/?group_id=1453

You also may want to get LiveHTTPHeaders for FireFox and compare the
output of that to your mechanize logs.

With browser, it works.

Thank you for any help!

Axel
[snip]

Can you turning on logging, and forward that to the mechanize mailing
list?

I’ll try it this evening (because it is a private job). Logging is done
like this, right?:

require ‘logger’
agent = WWW::Mechanize.new {|a| a.log = Logger.new(STDERR) }

Yes, I’ll send the results to the mailing list.

You also may want to get LiveHTTPHeaders for FireFox and compare the
output of that to your mechanize logs.

Interesting, did not know about this; that will be my second step.

  • Axel

On Mon, Nov 06, 2006 at 06:15:16PM +0900, Axel wrote:

Can you turning on logging, and forward that to the mechanize mailing
list?

I’ll try it this evening (because it is a private job). Logging is done
like this, right?:

require ‘logger’
agent = WWW::Mechanize.new {|a| a.log = Logger.new(STDERR) }

That is correct, or you can have it go to a file:
agent = WWW::Mechanize.new {|a| a.log = Logger.new(“some_file.txt”) }