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

Reply via email to