Skip Menu |

This queue is for tickets about the libwww-perl CPAN distribution.

Report information
The Basics
Id: 110893
Status: resolved
Priority: 0/
Queue: libwww-perl

People
Owner: Nobody in particular
Requestors: jonathan.dolle [...] groupsquad.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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
On 2016-01-04 06:15:54, jonathan.dolle@groupsquad.com wrote: Show quoted text
> 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.
Confirmed with LWP 6.15 and perl 5.22.1 using the following oneliner (timeout.cgi does what its name says, "d" param is the timeout duration): perl -MLWP -e 'my $lwp = LWP::UserAgent->new(keep_alive => 5); for my $timeout (2, 900) { $lwp->timeout($timeout); warn $lwp->get("http://home/test/timeout.cgi?d=" . ($timeout < 60 ? "1" : "60"))->as_string}'