Re: conns debug only in http10.pm - why?
Gisle Aas <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.lwp |
|---|---|
| Message-ID | <[email protected]> |
> Ethereal will not, I believe, work with HTTPS.
True. This show another approach to connection level debugging that
can easily be made to work for https as well.
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new(keep_alive => 1, cookie_jar => {});
if ($ENV{LWP_DEBUG}) {
require Data::Dump;
package LWP::Protocol::http::Socket;
no strict 'refs';
*{"syswrite"} = sub {
my $self = shift;
my $n = $self->SUPER::syswrite(@_);
print "==> ", Data::Dump::dump("".substr($_[0], 0, $n)), "\n" if $n;
return $n;
};
*{"sysread"} = sub {
my $self = shift;
my $n = $self->SUPER::sysread(@_);
print "<== ", Data::Dump::dump($_[0]), "\n" if $n;
return $n;
};
}
# make request
my $res = $ua->get("http://www.google.com");
print $res->status_line, "\n";