Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Debugging LWP and family

by rootcho (Pilgrim)
on May 16, 2007 at 02:08 UTC ( #615669=CUFP: print w/replies, xml ) Need Help??

Debugging Mech,LWP...
Here is a good way to debug request->responses that are going between LWP and the web server.
use Aspect; my $pcut = call qr/LWP::UserAgent::send_request/; before { my $ctx = shift; print "req================\n"; print $ctx->params->[1]->as_string; } $pcut; after { my $ctx = shift; print "resp----------------\n"; print $ctx->return_value->headers->as_string; print "==================\n"; } $pcut; use WWW::Mechanize; my $m = WWW::Mechanize->new; $m->get("");

req================ GET Accept-Encoding: identity User-Agent: WWW-Mechanize/1.14 resp---------------- Cache-Control: private Date: Wed, 16 May 2007 17:08:09 GMT Server: GWS/2.1 Content-Length: 3971 Content-Type: text/html; charset=ISO-8859-1 Content-Type: text/html; charset=ISO-8859-1 Client-Date: Wed, 16 May 2007 17:10:46 GMT Client-Peer: x.x.x.x:80 Client-Response-Num: 1 Set-Cookie: PREF=ID=f76dcf3c38b51e16:TM=1179335289:LM=1179335289:S=WLL +o_3xLrawI8ife; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain= Title: Google ==================
You can use $c->return_value->as_string, if u want to get the content of the response too. And of course you need to install module ;)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://615669]
Approved by planetscape
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2016-10-21 17:11 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (289 votes). Check out past polls.