HTTP-Tiny

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


0.080     2021-11-05 08:15:46-04:00 America/New_York

    - No changes from 0.079-TRIAL.

0.079     2021-11-04 12:33:43-04:00 America/New_York (TRIAL RELEASE)

    [FIXED]

    - Fixed uninitialized value warnings on older Perls when the REQUEST_METHOD
      environment variable is set and CGI_HTTP_PROXY is not.

0.078     2021-08-02 09:24:03-04:00 America/New_York

    - No changes from 0.077-TRIAL.

0.077     2021-07-22 13:07:14-04:00 America/New_York (TRIAL RELEASE)

    [ADDED]

    - Added a `patch` helper method for the HTTP `PATCH` verb.

    - If the REQUEST_METHOD environment variable is set, then CGI_HTTP_PROXY
      replaces HTTP_PROXY.

    [FIXED]

    - Unsupported scheme errors early without giving an uninitialized value
      warning first.

    - Sends Content-Length: 0 on empty body PUT/POST.  This is not in the spec,
      but some servers require this.

    - Allows optional status line reason, as clarified in RFC 7230.

Changes  view on Meta::CPAN

    - Added more fallback paths to find CA files (thanks golang)

    [DOCUMENTED]

    - Fixed a typo

0.053     2014-12-11 23:42:17-05:00 America/New_York

    [FIXED]

    - Defended tests against HTTP_PROXY set in the environment

0.052     2014-12-11 15:23:54-05:00 America/New_York

    [CHANGED]

    - Proxy allowed from environment variable HTTP_PROXY (uppercase) unless
      REQUEST_METHOD is also set.

0.051     2014-11-17 22:58:44-05:00 America/New_York

    [FIXED]

    - Checks for threads without loading threads.pm

0.050     2014-09-23 15:30:18-04:00 America/New_York

README  view on Meta::CPAN

    controlling the choice of cipher used for the TLS/SSL connection. See
    IO::Socket::SSL documentation for details.

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

    HTTP::Tiny supports the following proxy environment variables:

    *   http_proxy or HTTP_PROXY

    *   https_proxy or HTTPS_PROXY

    *   all_proxy or ALL_PROXY

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

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

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

    The "no_proxy" environment variable is supported in the format of a

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};
    }

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.

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();



( run in 2.447 seconds using v1.01-cache-2.11-cpan-71847e10f99 )