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
°°°°°°°°°°°°°°°°°°°°°
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html>
...
<!-- Wenn man nicht von start.jsp kommt, dann FS loesen (zB neutrale
Login Seite)-->
<script type="text/javascript">
if (parent.frames.length > 0 && parent.frames[0].name != 'mainframe')
  parent.location="/diverse/indexKunde.jsp;jsessionid=fafdsfsd!-132!-12132";
</script>

<frameset rows="100,*" framespacing="0" border="0" frameborder="0">
  <frame name="head"
src="/brokerdesign/default/head.jsp;jsessionid=fafdsfsd!-132!-12132"
scrolling="no" marginwidth="0" marginheight="0" noresize=""/>
  <frameset cols="199,*" framespacing="0" border="0" frameborder="0">
    <frameset rows="*,75,0" framespacing="0" border="0" frameborder="0">
        <frame name="nav"
src="../diverse/navigation.jsp;jsessionid=fafdsfsd!-132!-12132?menu=1"
scrolling="no" marginwidth="0" marginheight="0" noresize=""/>
        <frame name="ffblogo"
src="../diverse/ffblogoKunde.jsp;jsessionid=fafdsfsd!-132!-12132"
scrolling="no" marginwidth="0" marginheight="0" noresize=""/>
                    <frame name="keepSessionAlive"
src="../images/spacer.gif" scrolling="no" marginwidth="0"
marginheight="0" noresize=""/>
    </frameset>
    <frame name="main"
src="../action/depotuebersichtinit;jsessionid=fafdsfsd!-132!-12132"
scrolling="auto" marginwidth="0" marginheight="0" noresize=""/>
  </frameset>
        <noframes>
        </noframes>
</frameset>
</html>

Hi Axel,

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]

···

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

--
Aaron Patterson
http://tenderlovemaking.com/

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

> 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") }

···

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

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

--
Aaron Patterson
http://tenderlovemaking.com/