Subject: | Client-Peer header not set on 'internal' errors, such as socket I/O errors |
Date: | Fri, 13 Feb 2015 15:52:27 +0000 (UTC) |
To: | "bug-libwww-perl [...] rt.cpan.org" <bug-libwww-perl [...] rt.cpan.org> |
From: | tlhackque <tlhackque [...] yahoo.com> |
Given this:
$url = 'http://' . <something broken>'' # I can't guarantee that
what's broken for me now will be when you get to this bug!
$file = "foo.txt";
$verbose = 2;
$ua = LWP::UserAgent->new;
print STDERR ("Contacting $url for $file\n") if( $verbose > 1 );
my $rsp = $ua->mirror( $url, $file );
unless( $rsp->is_success || $rsp->code == 304 ) { # Yes, even if $verbose == 0
my $peer = $rsp->header( 'Client-Peer' ) || '';
$peer = " from $peer" if( $peer );
print STDERR ("ERROR: ", $rsp->status_line, "$peer\n");
}
I get:
Contacting ... for ...
Result: 500 Status read failed: Connection reset by peer #<< no $peer
Dumping the $rsp, we see that 'Client-Peer' is not set.
It would be useful to report which server is resetting the connection so it can be fixed :-)
Although this example shows a read failing, I assume that a write (e.g. sending the request)
can also fail without setting the Client-Peer header.
Note that it's not as simple as reporting the URL in the client - redirects and multi-homed hosts
require that LWP actually set the header from the failing socket, as it does for other
errors; e.g. 404.
libwww-perl V6.10
Thanks.
---------------------------------------------------------
This communication may not represent my employer's views,
if any, on the matters discussed.