Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: frioux [...] gmail.com
Cc:
AdminCc:

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



Subject: silently fails when not passed a URI object
pass a string instead of a URI object to GET and nothing happens
On Sat Oct 05 17:15:40 2013, frew wrote: Show quoted text
> pass a string instead of a URI object to GET and nothing happens
Now fixed; allows a plain string as the 'uri' parameter, transparently upgrading it to a URI object internally. Will be in next release. -- Paul Evans
Subject: rt89269.patch
=== modified file 'lib/Net/Async/HTTP.pm' --- lib/Net/Async/HTTP.pm 2013-10-20 02:09:59 +0000 +++ lib/Net/Async/HTTP.pm 2013-10-31 18:33:44 +0000 @@ -21,12 +21,14 @@ use HTTP::Request; use HTTP::Request::Common qw(); +use URI; use IO::Async::Stream 0.59; use IO::Async::Loop 0.59; # ->connect( handle ) ==> $stream use Future::Utils 0.16 qw( repeat ); +use Scalar::Util qw( blessed ); use Socket qw( SOCK_STREAM IPPROTO_IP IP_TOS ); BEGIN { if( $Socket::VERSION >= '2.010' ) { @@ -419,10 +421,10 @@ =over 8 -=item uri => URI +=item uri => URI or STRING -A reference to a C<URI> object. If the scheme is C<https> then an SSL -connection will be used. +A reference to a C<URI> object, or a plain string giving the request URI. If +the scheme is C<https> then an SSL connection will be used. =item method => STRING @@ -761,7 +763,12 @@ my $self = shift; my ( $uri, %args ) = @_; - ref $uri and $uri->isa( "URI" ) or croak "Expected 'uri' as a URI reference"; + if( !ref $uri ) { + $uri = URI->new( $uri ); + } + elsif( blessed $uri and !$uri->isa( "URI" ) ) { + croak "Expected 'uri' as a URI reference"; + } my $method = delete $args{method} || "GET"; === modified file 't/02uri.t' --- t/02uri.t 2013-09-10 00:28:12 +0000 +++ t/02uri.t 2013-10-31 18:33:44 +0000 @@ -308,4 +308,20 @@ expect_res_content => "Done", ); +do_test_uri( "plain string URI", + method => "GET", + uri => "http://host7/path", + + expect_req_firstline => "GET /path HTTP/1.1", + expect_req_headers => { + Host => "host7", + }, + + response => "HTTP/1.1 200 OK$CRLF" . + "Content-Length: 0$CRLF" . + "$CRLF", + + expect_res_code => 200, +); + done_testing;
Released in 0.31. -- Paul Evans