=== 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;