Subject: | patch to add credentials |
When making a request with userinfo, eg. http://user:pass@example.com/ , LWP converts that into an Authorization header, like 'Authorization: Basic ...'. But LWP::Protocol::AnyEvent::http doesn't handle this. Attached is a patch that calls LWP::Protocol::http's _fixup_header function to accomplish this.
Subject: | creds.patch |
diff --git a/lib/LWP/Protocol/AnyEvent/http.pm b/lib/LWP/Protocol/AnyEvent/http.pm
index 0ea94b8..16c2cac 100644
--- a/lib/LWP/Protocol/AnyEvent/http.pm
+++ b/lib/LWP/Protocol/AnyEvent/http.pm
@@ -10,6 +10,7 @@ use AnyEvent qw( );
use AnyEvent::HTTP qw( http_request );
use HTTP::Response qw( );
use LWP::Protocol qw( );
+use LWP::Protocol::http qw ( );
our @ISA = 'LWP::Protocol';
@@ -87,8 +88,12 @@ sub request {
my $method = $request->method();
my $url = $request->uri();
- my %headers; $request->headers()->scan(sub { $headers{ lc($_[0]) } = $_[1]; });
- my $body = $request->content_ref();
+
+ my $headers = $request->headers->clone();
+ LWP::Protocol::http->_fixup_header($headers, $url, $proxy);
+ my %headers; $headers->scan(sub { $headers{ lc($_[0]) } = $_[1]; });
+
+ my $body = $request->content_ref();
# Fix AnyEvent::HTTP setting Referer to the request URL
$headers{referer} = undef unless exists $headers{referer};