Subject: | Bug in LWP::UserAgent + LWP::Protocol::http : keep_alive vs timeout |
Date: | Mon, 4 Jan 2016 12:15:30 +0100 |
To: | bug-libwww-perl [...] rt.cpan.org |
From: | Jonathan Dollé <jonathan.dolle [...] groupsquad.com> |
Hello,
It seems that there is a bug in the way LWP::Protocol::http handles
timeout when using a connection cache.
When you do something like this :
my $lwp = LWP::UserAgent->new(keep_alive => 5);
$lwp->timeout(2);
$lwp->get('https://www.example.com/first');
$lwp->timeout(900);
$lwp->get('https://www.example.com/second');
The second request will timeout after 2 seconds, not 900.
I think the bug is in the LWP::Protocol::http::request function : when
$conn_cache is true (and it is, because of the keep_alive parameter),
when you reuse the socket, you don't apply the new timeout !
I produced the bug with perl 5.20.2 and LWP::UserAgent 6.06. But I think
the bug is still present in the current version.
Best regards,
Jonathan Dolle