=== modified file 'lib/Net/Async/HTTP/Connection.pm'
--- lib/Net/Async/HTTP/Connection.pm 2013-11-01 20:55:57 +0000
+++ lib/Net/Async/HTTP/Connection.pm 2013-11-01 22:08:47 +0000
@@ -468,7 +468,15 @@
my $uri = $req->uri;
$path = $uri->path_query;
$path = "/$path" unless $path =~ m{^/};
- $headers->init_header( Host => $uri->authority );
+ my $authority = $uri->authority;
+ if( defined $authority and
+ my ( $user, $pass, $host ) = $authority =~ m/^(.*?):(.*)@(.*)$/ ) {
+ $headers->init_header( Host => $host );
+ $headers->authorization_basic( $user, $pass );
+ }
+ else {
+ $headers->init_header( Host => $authority );
+ }
}
my $protocol = $req->protocol || "HTTP/1.1";
=== modified file 't/01request.t'
--- t/01request.t 2013-09-13 19:39:45 +0000
+++ t/01request.t 2013-11-01 22:08:47 +0000
@@ -478,4 +478,25 @@
expect_res_code => 200,
);
+$req = HTTP::Request->new( GET => "
http://user:pass\@somehost2/with/secret" );
+
+do_test_req( "request-implied authentication",
+ req => $req,
+ no_host => 1,
+
+ expect_req_firstline => "GET /with/secret HTTP/1.1",
+ expect_req_headers => {
+ Host => "somehost2",
+ Authorization => "Basic dXNlcjpwYXNz", # determined using 'wget'
+ },
+
+ response => "HTTP/1.1 200 OK$CRLF" .
+ "Content-Length: 4$CRLF" .
+ "Content-Type: text/plain$CRLF" .
+ $CRLF .
+ "Booo",
+
+ expect_res_code => 200,
+);
+
done_testing;