Skip Menu |

This queue is for tickets about the Net-Async-HTTP CPAN distribution.

Report information
The Basics
Id: 88996
Status: resolved
Priority: 0/
Queue: Net-Async-HTTP

People
Owner: Nobody in particular
Requestors: TEAM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.27
  • 0.27_001
  • 0.27_002
  • 0.28
  • 0.29
Fixed in: 0.30



Subject: fail_on_error fails on success
Setting: fail_on_error => 1 works really well when the server returns 4xx/5xx responses, which is great. Unfortunately, all 'successful' (2xx/3xx) requests start throwing this error: IO::Async::Future=HASH(0x35778b0) is already complete and cannot be ->done twice at /usr/local/share/perl/5.14.2/Net/Async/HTTP/Connection.pm line 408 which is mildly unfortunate. I think the fix here is just 'return $f;' instead of 'return $resp;', can probably throw together a test case this evening if that'd help. cheers, Tom
On Fri Sep 27 03:55:13 2013, TEAM wrote: Show quoted text
> I think the fix here is just 'return $f;' instead of 'return $resp;', > can probably throw together a test case this evening if that'd help.
Yeah; having done ->and_then for the specific purpose of returning $f instead of $resp as well. Patch attached. -- Paul Evans
Subject: rt88996.patch
=== modified file 'lib/Net/Async/HTTP.pm' --- lib/Net/Async/HTTP.pm 2013-09-22 01:52:31 +0000 +++ lib/Net/Async/HTTP.pm 2013-09-27 12:01:10 +0000 @@ -676,7 +676,7 @@ return Future->new->fail( "$code $message", $resp, $request ); } - return $resp; + return $f; }); } === modified file 't/04fail.t' --- t/04fail.t 2013-09-10 00:28:12 +0000 +++ t/04fail.t 2013-09-27 12:01:10 +0000 @@ -114,6 +114,28 @@ is( $request_f->uri, "http://host0/some/path", '$request_f->uri for fail_on_error true' ); is( $request_c->uri, "http://host0/some/path", '$request_f->uri for fail_on_error true' ); + + # Now check that non-errors don't fail + $future = $http->do_request( + method => "GET", + uri => URI->new( "http://host0/other/path" ), + ); + + $request_stream = ""; + wait_for_stream { $request_stream =~ m/$CRLF$CRLF/ } $peersock => $request_stream; + + $peersock->syswrite( join( $CRLF, + "HTTP/1.1 200 OK", + "Content-Type: text/plain", + "Content-Length: 9", + "" ) . $CRLF . + "Here I am" + ); + + wait_for { $future->is_ready }; + my $response = $future->get; + + is( $response->code, 200, '$response->code for non-fail' ); } done_testing;
Was released in 0.30 -- Paul Evans