Debugging Tip for the mech FAQ

Peter Stevens <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
Hi Andy -

Here is a candidate for the mech FAQ:

I just discovered Tamper, a neat tool for Firefox which helps debugging 
mech problems. I think it will also be useful for people trying to 
figure out what a particular piece of javascript is doing. (This is 
probably old hat for most people out there, but it was news - and 
helpful - to me.)

Q: When I request a page, it works with my browser, but when I use mech, 
it doesn't. Why not?

A: Everything the web server knows about the client is passed back and 
forth using the HTTP protocol. This information includes the URI, GET 
and POST parameters, cookies, and other header information. If you can 
make mech send exactly the same information, then you should get exactly 
the same results. (I say "should" because there may be some timing 
issues as well - your mech program will normally run much faster than a 
human can click a browser and that may have an impact in some 
circumstances).

How do you find out what the browser sent? Well, you could sniff the 
network, but much easier is to use Firefox. Get the extension "Tamper". 
When activated, it keeps a log of all the http requests and responses, 
and allows you to examine the headers, cookies, parameters, etc. This is 
particularly useful when trying to figure out what some javascript does, 
because you can clearly see the results of script in terms of the 
parameters transmitted.

Cheers,

Peter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.