Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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 ;)

Comment on Debugging LWP and family
Select or Download Code

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 scrutinizing the Monastery: (10)
As of 2014-09-01 13:11 GMT
Find Nodes?
    Voting Booth?

    My favorite cookbook is:

    Results (11 votes), past polls