unsupported
  0   lΠzΎClΚy@ΰΈΫjbΡΏΖuα6Χ_uΠb&=LV[(ΓΕ ?χ     # vim: ts=4 sts=4 sw=4 et:
package HTTP::Tiny;
use strict;
use warnings;
# ABSTRACT: A small, simple, correct HTTP/1.1 client

our $VERSION = '0.076';

sub _croak { require Carp; Carp::croak(@_) }

#pod =method new
#pod
#pod     $http = HTTP::Tiny->new( %attributes );
#pod
#pod This constructor returns a new HTTP::Tiny object.  Valid attributes include:
#pod
#pod =for :list
#pod * C<agent> β A user-agent string (defaults to 'HTTP-Tiny/$VERSION'). If
#pod   C<agent> β ends in a space character, the default user-agent string is
#pod   appended.
#pod * C<cookie_jar> β An instance of L<HTTP::CookieJar> β or equivalent class
#pod   that supports the C<add> and C<cookie_header> methods
#pod * C<default_headers> β A hashref of default headers to apply to requests
#pod * C<local_address> β The local IP address to bind to
#pod * C<keep_alive> β Whether to reuse the last connection (if for the same
#pod   scheme, host and port) (defaults to 1)
#pod * C<max_redirect> β Maximum number of redirects allowed (defaults to 5)
#pod * C<max_size> β Maximum response size in bytes (only when not using a data
#pod   callback).  If defined, responses larger than this will return an
#pod   exception.
#pod * C<http_proxy> β URL of a proxy server to use for HTTP connections
#pod   (default is C<$ENV{http_proxy}> β if set)
#pod * C<https_proxy> β URL of a proxy server to use for HTTPS connections
#pod   (default is C<$ENV{https_proxy}> β if set)
#pod * C<proxy> β URL of a generic proxy server for both HTTP and HTTPS
#pod   connections (default is C<$ENV{all_proxy}> β if set)
#pod * C<no_proxy> β List of domain suffixes that should not be proxied.  Must
#pod   be a comma-separated string or an array reference. (default is
#pod   C<$ENV{no_proxy}> β)
#pod * C<timeout> β Request timeout in seconds (default is 60) If a socket open,
#pod   read or write takes longer than the timeout, an exception is thrown.
#pod * C<verify_SSL> β A boolean that indicates whether to validate the SSL
#pod   certificate of an C<https> β connection (default is false)
#pod * C<SSL_options> β A hashref of C<SSL_*> β options to pass through to
#pod   L<IO::Socket::SSL>
#pod
#pod Passing an explicit C<undef> for C<proxy>, C<http_proxy> or C<https_proxy> will
#pod prevent getting the corresponding proxies from the environment.
#pod
#pod Exceptions from C<max_size>, C<timeout> or other errors will result in a
#pod pseudo-HTTP status code of 599 and a reason of "Internal Exception". The
#pod content field in the response will contain the text of the exception.
#pod
#pod The C<keep_alive> parameter enables a persistent connection, but only to a
#pod single destination scheme, host and port.  Also, if any connection-relevant
#pod attributes are modified, or if the process ID or thread ID change, the
#pod persistent connection will be dropped.  If you want persistent connections
#pod across multiple destinations, use multiple HTTP::Tiny objects.
#pod
#pod See L</SSL SUPPORT> for more on the C<verify_SSL> and C<SSL_options> attributes.
#pod
#pod =cut

my @attributes;
BEGIN {
    @attributes = qw(
        cookie_jar default_headers http_proxy https_proxy keep_alive
        local_address max_redirect max_size proxy no_proxy
        SSL_options verify_SSL
    );
    my %persist_ok = map {; $_ => 1 } qw(
        cookie_jar default_headers max_redirect max_size
    );
    no strict 'refs';
    no warnings 'uninitialized';
    for my $accessor ( @attributes ) {
        *{$accessor} = sub {
            @_ > 1
                ? do {
                    delete $_[0]->{handle} if !$persist_ok{$accessor} && $_[1] ne $_[0]->{$accessor};
                    $_[0]->{$accessor} = $_[1]
                }
                : $_[0]->{$accessor};
        };
    }
}

sub agent {
    my($self, $agent) = @_;
    if( @_ > 1 ){
        $self->{agent} =
            (defined $agent && $agent =~ / $/) ? $agent . $self->_agent : $agent;
    }
    return $self->{agent};
}

sub timeout {
    my 