perl

 view release on metacpan or  search on metacpan

cpan/CPAN/lib/CPAN/LWP/UserAgent.pm  view on Meta::CPAN

}

# mirror(): Its purpose is to deal with proxy authentication. When we
# call SUPER::mirror, we really call the mirror method in
# LWP::UserAgent. LWP::UserAgent will then call
# $self->get_basic_credentials or some equivalent and this will be
# $self->dispatched to our own get_basic_credentials method.

# Our own get_basic_credentials sets $USER and $PASSWD, two globals.

# 407 stands for HTTP_PROXY_AUTHENTICATION_REQUIRED. Which means
# although we have gone through our get_basic_credentials, the proxy
# server refuses to connect. This could be a case where the username or
# password has changed in the meantime, so I'm trying once again without
# $USER and $PASSWD to give the get_basic_credentials routine another
# chance to set $USER and $PASSWD.

sub mirror {
    my($self,$url,$aslocal) = @_;
    my $result = $self->SUPER::mirror($url,$aslocal);
    if ($result->code == 407) {

cpan/HTTP-Tiny/lib/HTTP/Tiny.pm  view on Meta::CPAN


    if ( defined $self->{proxy} ) {
        $self->_split_proxy( 'generic proxy' => $self->{proxy} ); # validate
    }
    else {
        delete $self->{proxy};
    }

    # http proxy
    if (! exists $self->{http_proxy} ) {
        # under CGI, bypass HTTP_PROXY as request sets it from Proxy header
        local $ENV{HTTP_PROXY} = ($ENV{CGI_HTTP_PROXY} || "") if $ENV{REQUEST_METHOD};
        $self->{http_proxy} = $ENV{http_proxy} || $ENV{HTTP_PROXY} || $self->{proxy};
    }

    if ( defined $self->{http_proxy} ) {
        $self->_split_proxy( http_proxy => $self->{http_proxy} ); # validate
        $self->{_has_proxy}{http} = 1;
    }
    else {
        delete $self->{http_proxy};
    }

cpan/HTTP-Tiny/lib/HTTP/Tiny.pm  view on Meta::CPAN

HTTP::Tiny can proxy both C<http> and C<https> requests.  Only Basic proxy
authorization is supported and it must be provided as part of the proxy URL:
C<http://user:pass@proxy.example.com/>.

HTTP::Tiny supports the following proxy environment variables:

=over 4

=item *

http_proxy or HTTP_PROXY

=item *

https_proxy or HTTPS_PROXY

=item *

all_proxy or ALL_PROXY

=back

If the C<REQUEST_METHOD> environment variable is set, then this might be a CGI
process and C<HTTP_PROXY> would be set from the C<Proxy:> header, which is a
security risk.  If C<REQUEST_METHOD> is set, C<HTTP_PROXY> (the upper case
variant only) is ignored, but C<CGI_HTTP_PROXY> is considered instead.

Tunnelling C<https> over an C<http> proxy using the CONNECT method is
supported.  If your proxy uses C<https> itself, you can not tunnel C<https>
over it.

Be warned that proxying an C<https> connection opens you to the risk of a
man-in-the-middle attack by the proxy server.

The C<no_proxy> environment variable is supported in the format of a
comma-separated list of domain extensions proxy should not be used for.

cpan/HTTP-Tiny/t/140_proxy.t  view on Meta::CPAN

for my $var ( qw/http_proxy https_proxy all_proxy/ ) {
    my $proxy = "http://localhost:8080";
    for my $s ( uc($var), lc($var) ) {
        local $ENV{$s} = $proxy;
        my $c = HTTP::Tiny->new();
        my $m = ($s =~ /all/i) ? 'proxy' : lc($s);
        is( $c->$m, $proxy, "set $m from $s" );
    }
}

# ignore HTTP_PROXY with REQUEST_METHOD
{
    # in case previous clean-up failed for some reason
    delete local @ENV{'http_proxy', 'https_proxy', 'all_proxy',
                      'HTTP_PROXY', 'HTTPS_PROXY', 'ALL_PROXY'};

    local $ENV{HTTP_PROXY} = "http://localhost:8080";
    local $ENV{REQUEST_METHOD} = 'GET';
    my $c = HTTP::Tiny->new();
    ok(!defined $c->http_proxy,
        "http_proxy not set from HTTP_PROXY if REQUEST_METHOD set");

}

# allow CGI_HTTP_PROXY with REQUEST_METHOD
{
    local $ENV{HTTP_PROXY} = "http://localhost:8080";
    local $ENV{CGI_HTTP_PROXY} = "http://localhost:9090";
    local $ENV{REQUEST_METHOD} = 'GET';
    my $c = HTTP::Tiny->new();
    is($c->http_proxy, "http://localhost:9090",
        "http_proxy set from CGI_HTTP_PROXY if REQUEST_METHOD set");
}

done_testing();

cpan/Win32/Win32.xs  view on Meta::CPAN

    }

    /* Call WinHttpGetProxyForUrl with our target URL. If auto-proxy succeeds,
     * then set the proxy info on the request handle. If auto-proxy fails,
     * ignore the error and attempt to send the HTTP request directly to the
     * target server (using the default WINHTTP_ACCESS_TYPE_NO_PROXY
     * configuration, which the request handle will inherit from the session).
     */
    if (hRequest && !bAborted) {
        WINHTTP_AUTOPROXY_OPTIONS  AutoProxyOptions;
        WINHTTP_PROXY_INFO         ProxyInfo;
        DWORD                      cbProxyInfoSize = sizeof(ProxyInfo);

        ZeroMemory(&AutoProxyOptions, sizeof(AutoProxyOptions));
        ZeroMemory(&ProxyInfo, sizeof(ProxyInfo));
        AutoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT;
        AutoProxyOptions.dwAutoDetectFlags =
                                    WINHTTP_AUTO_DETECT_TYPE_DHCP |
                                    WINHTTP_AUTO_DETECT_TYPE_DNS_A;
        AutoProxyOptions.fAutoLogonIfChallenged = TRUE;



( run in 1.593 second using v1.01-cache-2.11-cpan-6b5c3043376 )