Control: tag -1 patch On Sat, Sep 12, 2015 at 09:42:16PM +0300, Niko Tyni wrote: > Package: libhttp-proxy-perl > Version: 0.304-1 > Severity: important > Tags: upstream > Forwarded: https://github.com/book/HTTP-Proxy/issues/7 > > There's apparently a timing problem in t/23connect.t > that makes it fail non-determistically with > > t/23connect.t .. > 1..4 > ok - The proxy accepts CONNECT requests > not ok - Read some data from the socket > not ok - CONNECTed to the TCP server and got the banner > > # Failed test 'Read some data from the socket' > # at t/23connect.t line 78. > > # Failed test 'CONNECTed to the TCP server and got the banner' > # at t/23connect.t line 79. > # got: undef > # expected: 'President_of_Earth Barbarella Professor_Ping Stomoxys > Dildano > # '
As I wrote in the upstream bug, this is a problem with unwanted Net::HTTP (as used by LWP::UserAgent) buffering. It's possible for the LWP::UserAgent request() call to get both the headers and (parts of) the body in the same read(2) call. When that happens, Net::HTTP (as used by LWP::UserAgent) will buffer the body, but the explicit read() call on the socket bypasses this buffering, resulting in empty data. The attached patch just marks the resulting test failures as TODO when this happens by breaking encapsulation and peeking in the Net::HTTP buffer. Note that this is a hack and not a proper fix, but I think it's good enough for the Debian package. -- Niko Tyni nt...@debian.org
>From 06c067ccf385931369b4c324c4cdc3b54c6dbcfa Mon Sep 17 00:00:00 2001 From: Niko Tyni <nt...@debian.org> Date: Fri, 16 Oct 2015 20:08:42 +0300 Subject: [PATCH] Work around LWP::UserAgent / Net::HTTP buffering It's possible for the LWP::UserAgent request() call to get both the headers and (parts of) the body in the same read(2) call. When that happens, Net::HTTP (as used by LWP::UserAgent) will buffer the body, but the explicit read() call on the socket bypasses this buffering, resulting in empty data. Mark the resulting test failures as TODO by breaking encapsulation and peeking in the Net::HTTP buffer. Note that this is a hack and not a proper fix. Bug-Debian: https://bugs.debian.org/798792 Bug: https://github.com/book/HTTP-Proxy/issues/7 --- t/23connect.t | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/t/23connect.t b/t/23connect.t index d1b5ff2..5f25aed 100644 --- a/t/23connect.t +++ b/t/23connect.t @@ -67,6 +67,9 @@ plan tests => 4; # what does the proxy say? is( $res->code, 200, "The proxy accepts CONNECT requests" ); + TODO: { + local $TODO = "problems with Net::HTTP buffering, see https://github.com/book/HTTP-Proxy/issues/7" + if $sock->can("_rbuf") and $sock->_rbuf ne ''; # read a line my $read; eval { @@ -77,6 +80,7 @@ plan tests => 4; ok( $read, "Read some data from the socket" ); is( $read, $banner, "CONNECTed to the TCP server and got the banner" ); + } close $sock; # make sure the kids are dead -- 2.5.1