PoCo::Client::HTTPで認証付きプロキシを使えるようにする

タイトルの通り.

$ENV{HTTP_PROXY} = "http://username:password@proxy.example.com:8080";

みたいなときのために.

--- POE/Component/Client/HTTP/RequestFactory.pm~	2006-10-15 11:56:47.000000000 +0900
+++ POE/Component/Client/HTTP/RequestFactory.pm	2007-11-07 08:13:19.000000000 +0900
@@ -297,6 +297,18 @@
       !defined($host) or
       _in_no_proxy ($host, $self->[FCT_NOPROXY])
     );
+
+    # Proxy-Authorization: for "username:password@proxy.host"
+    if ($proxy) {
+      for my $def (@$proxy) {
+        my $uri = URI->new("http://" . $def->[0]);
+        if ($uri->userinfo) {
+          $http_request->proxy_authorization_basic(split /:/ => $uri->userinfo);
+          $def->[0] = $uri->host;
+          last;
+        }
+      }
+    }
   }
 
   my $request = POE::Component::Client::HTTP::Request->new (