Skip Menu |

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

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

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

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



Subject: Variable $on_header is not available
As mentioned in IRC: Variable "$on_header" is not available at /home/tom/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/Net/Async/HTTP.pm line 401 (#1) This should be enough to trigger it: perl examples/GET.pl http://www.google.com Moving the my $on_header declaration up a line fixes it - attached a slightly rewritten patch which works for me locally. cheers, Tom
Subject: Net-Async-HTTP-0.12-on_header.diff
--- a/lib/Net/Async/HTTP.pm 2011-10-03 19:10:08.000000000 +0100 +++ b/lib/Net/Async/HTTP.pm 2011-10-08 15:27:50.235056997 +0100 @@ -338,8 +338,10 @@ my $self = shift; my %args = @_; - my $on_response = $args{on_response} or - my $on_header = $args{on_header} or croak "Expected 'on_response' or 'on_header' as CODE ref"; + my $on_response = $args{on_response}; + my $on_header = $args{on_header}; + croak "Expected 'on_response' or 'on_header' as CODE ref" unless $on_response || $on_header; + my $on_error = $args{on_error} or croak "Expected 'on_error' as a CODE ref"; my $request_body = $args{request_body};
On Sat Oct 08 10:32:04 2011, TEAM wrote: Show quoted text
> Moving the my $on_header declaration up a line fixes it - attached a > slightly rewritten patch which works for me locally.
Thanks. Fixed upstream slightly differently, by --- lib/Net/Async/HTTP.pm 2011-10-08 20:11:07 +0000 +++ lib/Net/Async/HTTP.pm 2011-10-08 20:35:39 +0000 @@ -338,9 +338,10 @@ my $self = shift; my %args = @_; - my $on_response = $args{on_response} or - my $on_header = $args{on_header} or croak "Expected 'on_response' or 'on_header' as CODE ref"; - my $on_error = $args{on_error} or croak "Expected 'on_error' as a CODE ref"; + my ( $on_response, $on_header ); + $on_response = $args{on_response} or + $on_header = $args{on_header} or croak "Expected 'on_response' or 'on_header' as CODE ref"; + my $on_error = $args{on_error} or croak "Expected 'on_error' as a CODE ref"; my $request_body = $args{request_body}; my $max_redirects = defined $args{max_redirects} ? $args{max_redirects} : $self->{max_redirects}; so as to preserve the side-effect that if $on_response gets defined, $on_header will not. Will be in next release. -- Paul Evans