Show
Ignore:
Timestamp:
10/08/08 19:35:04 (5 years ago)
Author:
kamipo
Message:

lang/perl/LWP-UserAgent?-ProxyConnect?: little fix

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/LWP-UserAgent-ProxyConnect/lib/LWP/UserAgent/ProxyConnect.pm

    r19136 r20972  
    77use LWP::UserAgent; 
    88 
    9 my $method; 
     9{ 
     10    use LWP::Protocol::http (); 
    1011 
    11 { 
    12     use LWP::Protocol::http; 
    13     no strict 'refs'; 
     12    my $orig = \&LWP::Protocol::http::request; 
    1413 
    15     $method = delete ${'LWP::Protocol::http::'}{request}; 
    16  
    17     *{'LWP::Protocol::http::request'} = sub { 
     14    my $method = sub { 
    1815        my ($self, $request, $proxy, $arg, $size, $timeout) = @_; 
    1916 
    20         if ((my $scheme = $request->url->scheme) eq 'https' and $proxy) { 
    21             my ($username, $password) = split /:/, ($proxy->userinfo || ''); 
     17        if ($request->url->scheme eq 'https' and $proxy) { 
     18            local $ENV{HTTPS_PROXY} = $proxy->host_port; 
    2219 
    23             local $ENV{HTTPS_PROXY} = $proxy->host_port; 
     20            no warnings 'uninitialized'; 
     21            my ($username, $password) = split /:/, $proxy->userinfo; 
    2422            local $ENV{HTTPS_PROXY_USERNAME} = $username; 
    2523            local $ENV{HTTPS_PROXY_PASSWORD} = $password; 
     24            use warnings 'uninitialized'; 
    2625 
    27             bless $self, LWP::Protocol::implementor($scheme); 
     26            bless $self, LWP::Protocol::implementor('https'); 
    2827 
    29             $method->($self, $request, undef, $arg, $size, $timeout); 
     28            $orig->($self, $request, undef, $arg, $size, $timeout); 
    3029        } 
    3130        else { 
    32             $method->(@_); 
     31            $orig->(@_); 
    3332        } 
    3433    }; 
     34 
     35    no strict 'refs'; 
     36    no warnings 'redefine'; 
     37    *{'LWP::Protocol::http::request'} = $method; 
    3538} 
    3639