nysus has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to look at the data and headers with the LWP::Debug module using the following code:
#!/usr/bin/perl -w use strict; use LWP; use LWP::Debug qw(+conns); my $agent = LWP::UserAgent->new(); my $url = 'http://www.perlmonks.org'; my $response = $agent->get($url);
According to the LWP::Debug manpage, "The conns() function is used to show data being transferred over the connections. This may generate considerable output." But for me, it generates zero output. It does produce output if I export the +debug and +trace functions. But that's not the data I'm after. I want the data that's supposedly output by the conns() function. Anyone out there familiar with this module and can see what I'm doing wrong?

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon";
$nysus = $PM . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re: Using LWP::Debug conns() function
by PodMaster (Abbot) on Nov 19, 2005 at 15:59 UTC
    Looking for LWP::Debug::conns (I have lwp 5.803), I see it appear in LWP::Protocol::http (commented out) and LWP::Protocol::http10 (often used). My little test shows no output
    perl -MLWP::Debug=+conns -MLWP::Simple -e get(shift) http://perl.org
    After looking at the LWP documentation, I enable PERL_LWP_USE_HTTP_10, and try again, and again no output.

    Then I remember LWP::Simple is simple (grrr), so I adapt your sample and try again (oy)

    #!/usr/bin/perl -w use strict; use LWP; use LWP::Debug qw(+conns); local $ENV{PERL_LWP_USE_HTTP_10} = 1; my $agent = LWP::UserAgent->new(); my $url = 'http://www.perlmonks.org'; my $response = $agent->get($url);
    and this time it works :)

    I would(you should) ask the author/maintainer about this, as it looks like something he's overlooked.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Thanks for the help. But setting that environment variable did not help. I still get no output. I'm using version 5.8.4. Correction: Like you, I'm also using 5.803.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon";
      $nysus = $PM . $MCF;
      Click here if you love Perl Monks

      Hmmm...on a whim I uncommented the line in http.pm you mentioned and now I can see the headers sent by the client. I don't see anything else, however. It works both with and without the $ENV variable setting. So that line doesn't seem to have an affect for me.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon";
      $nysus = $PM . $MCF;
      Click here if you love Perl Monks