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

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("http://www.google.com");

req================ GET http://www.google.com 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= +.google.com 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 Aspect.pm module ;)

Comment on Debugging LWP and family
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2015-05-27 21:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    In my home, the TV remote control is ...









    Results (546 votes), past polls