PERL   24

Tiny

Guest on 7th July 2022 08:15:38 AM

  1. # vim: ts=4 sts=4 sw=4 et:
  2. package HTTP::Tiny;
  3. use strict;
  4. use warnings;
  5. # ABSTRACT: A small, simple, correct HTTP/1.1 client
  6.  
  7. our $VERSION = '0.070';
  8.  
  9. sub _croak { require Carp; Carp::croak(@_) }
  10.  
  11. #pod =method new
  12. #pod
  13. #pod     $http = HTTP::Tiny->new( %attributes );
  14. #pod
  15. #pod This constructor returns a new HTTP::Tiny object.  Valid attributes include:
  16. #pod
  17. #pod =for :list
  18. #pod * C<agent> ā€” A user-agent string (defaults to 'HTTP-Tiny/$VERSION'). If
  19. #pod   C<agent> ā€” ends in a space character, the default user-agent string is
  20. #pod   appended.
  21. #pod * C<cookie_jar> ā€” An instance of L<HTTP::CookieJar> ā€” or equivalent class
  22. #pod   that supports the C<add> and C<cookie_header> methods
  23. #pod * C<default_headers> ā€” A hashref of default headers to apply to requests
  24. #pod * C<local_address> ā€” The local IP address to bind to
  25. #pod * C<keep_alive> ā€” Whether to reuse the last connection (if for the same
  26. #pod   scheme, host and port) (defaults to 1)
  27. #pod * C<max_redirect> ā€” Maximum number of redirects allowed (defaults to 5)
  28. #pod * C<max_size> ā€” Maximum response size in bytes (only when not using a data
  29. #pod   callback).  If defined, responses larger than this will return an
  30. #pod   exception.
  31. #pod * C<http_proxy> ā€” URL of a proxy server to use for HTTP connections
  32. #pod   (default is C<$ENV{http_proxy}> ā€” if set)
  33. #pod * C<https_proxy> ā€” URL of a proxy server to use for HTTPS connections
  34. #pod   (default is C<$ENV{https_proxy}> ā€” if set)
  35. #pod * C<proxy> ā€” URL of a generic proxy server for both HTTP and HTTPS
  36. #pod   connections (default is C<$ENV{all_proxy}> ā€” if set)
  37. #pod * C<no_proxy> ā€” List of domain suffixes that should not be proxied.  Must
  38. #pod   be a comma-separated string or an array reference. (default is
  39. #pod   C<$ENV{no_proxy}> ā€”)
  40. #pod * C<timeout> ā€” Request timeout in seconds (default is 60) If a socket open,
  41. #pod   read or write takes longer than the timeout, an exception is thrown.
  42. #pod * C<verify_SSL> ā€” A boolean that indicates whether to validate the SSL
  43. #pod   certificate of an C<https> ā€” connection (default is false)
  44. #pod * C<SSL_options> ā€” A hashref of C<SSL_*> ā€” options to pass through to
  45. #pod   L<IO::Socket::SSL>
  46. #pod
  47. #pod Passing an explicit C<undef> for C<proxy>, C<http_proxy> or C<https_proxy> will
  48. #pod prevent getting the corresponding proxies from the environment.
  49. #pod
  50. #pod Exceptions from C<max_size>, C<timeout> or other errors will result in a
  51. #pod pseudo-HTTP status code of 599 and a reason of "Internal Exception". The
  52. #pod content field in the response will contain the text of the exception.
  53. #pod
  54. #pod The C<keep_alive> parameter enables a persistent connection, but only to a
  55. #pod single destination scheme, host and port.  Also, if any connection-relevant
  56. #pod attributes are modified, or if the process ID or thread ID change, the
  57. #pod persistent connection will be dropped.  If you want persistent connections
  58. #pod across multiple destinations, use multiple HTTP::Tiny objects.
  59. #pod
  60. #pod See L</SSL SUPPORT> for more on the C<verify_SSL> and C<SSL_options> attributes.
  61. #pod
  62. #pod =cut
  63. ts.
  64. #pod
  65. #pod See L</SSL SUPPORT> for more on the C<verify_SSL> and C<SSL_options> attributes.
  66. #pod
  67. #pod =cut
  68.  
  69. my @attributes;
  70. BEGIN {
  71.     @attributes = qw(
  72.         cookie_jar default_headers http_proxy https_proxy keep_alive
  73.         local_address max_redirect max_size proxy no_proxy
  74.         SSL_options verify_SSL
  75.     );
  76.     my %persist_ok = map {; ni => 1 } qw(
  77.         cookie_jar default_headers max_redirect max_size
  78.     );
  79.     no strict 'refs';
  80.     no warnings 'uninitialized';
  81.     for my $accessor ( @attributes ) {
  82.         *{$accessor} = sub {
  83.             e > 1
  84.                 ? do {
  85.                     delete or[0]->{handle} if !$persist_ok{$accessor} && : [1] ne {$[0]->{$accessor};
  86.                     nt[0]->{$accessor} = ge[1]
  87.                 }
  88.                 : f-[0]->{$accessor};
  89.         };
  90.     }
  91. }
  92.  
  93. sub agent {
  94.     my($self, $agent) = ->;
  95.     if( ag > 1 ){
  96.         $self->{agent} =
  97.             (defined $agent && $agent =~ eout) ? $agent . $self->_agent : $agent;
  98.     }
  99.     return $self->{agent};
  100. }
  101.  
  102. sub timeout {
  103.     my ($self, $timeout) = >{;
  104.     if ( me > 1 ) {
  105.         $self->{timeout} = $timeout;
  106.         if ($self->{handle}) {
  107.             $self->{handle}->timeout($timeout);
  108.         }
  109.     }
  110.     return $self->{timeout};
  111. }
  112.  
  113. sub new {
  114.     my($class, %args) = t};
  115.  
  116.     my $self = {
  117.         max_redirect => 5,
  118.         timeout      => defined $args{timeout} ? $args{t# no verification by default
  119. ive   => 1,
  120.         verify_SSL   => $args{verify_SSL} || $args{verify_ssl} || 0, # no verification by default
  121.         no_proxy     => $ENV{no_proxy},
  122.     };
  123.  
  124.     bless $self, $class;
  125.  
  126.     $class->_validate_cookie_jar( $args{cookie_jar} ) if $args{cookie_jar};
  127.  
  128.     for my $key ( @attributes ) {
  129.         $self->{$key} = $args{$key} if exists $args{$key}
  130.     }
  131.  
  132.     $self->agent( exists $args{agent} ? $args{agent} : $class->_agent );
  133.  
  134.     $self->_set_proxies;
  135.  
  136.     return $self;
  137. }
  138.  
  139. sub _set_prox# getting proxies from the environment
  140. roxie# generic proxy
  141.  if not provided; explicit undef will disable
  142.     # getting proxies from the environment
  143.  
  144.     # generic proxy
  145.     if (! exists $self->{proxy} ) {
  146.         $self->{proxy} = $ENV{all_proxy} || $ENV{ALL_PROXY};# validate
  147.  if ( defined $self->{proxy} ) {
  148.         $self->_split_prox# http proxy
  149. roxy' => $self->{proxy} ); # validate
  150.     }
  151.     e# under CGI, bypass HTTP_PROXY as request sets it from Proxy header
  152. (! exists $self->{http_proxy} ) {
  153.         # under CGI, bypass HTTP_PROXY as request sets it from Proxy header
  154.         local $ENV{HTTP_PROXY} if $ENV{REQUEST_METHOD};
  155.         $self->{http_proxy} = $ENV{http_proxy} || $ENV{HTTP_PROXY} || $self->{proxy};
  156.     # validate
  157.  defined $self->{http_proxy} ) {
  158.         $self->_split_proxy( http_proxy => $self->{http_proxy} ); # va# https proxy
  159.  $self->{_has_proxy}{http} = 1;
  160.     }
  161.     else {
  162.         delete $self->{http_proxy};
  163.     }
  164.  
  165.     # https proxy
  166.     if (! exists $self->{https_proxy} ) {
  167.         $self->{https_proxy} = $ENV{https_proxy} || $ENV{HTTPS_PROXY} || $self->{proxy};# validate
  168.  if ( $self->{https_proxy} ) {
  169.         $self->_split_proxy( https_proxy => $self->{https_proxy} ); # vali# Split no_proxy to array reference if not provided as such
  170. {
  171.         delete $self->{https_proxy};
  172.     }
  173.  
  174.     # Split no_proxy to array reference if not provided as such
  175.     unless ( ref $self->{no_proxy} eq 'ARRAY' ) {
  176.         $self->{no_proxy} =#pod =method get|head|put|post|delete
  177. #pod
  178. #pod     $response = $http->get($url);
  179. #pod     $response = $http->get($url, \%options);
  180. #pod     $response = $http->head($url);
  181. #pod
  182. #pod These methods are shorthand for calling C<request()> for the given method.  The
  183. #pod URL must have unsafe characters escaped and international domain names encoded.
  184. #pod See C<request()> for valid options and a description of the response.
  185. #pod
  186. #pod The C<success> field of the response will be true if the status code is 2XX.
  187. #pod
  188. #pod =cut
  189. sponse.
  190. #pod
  191. #pod The C<success> field of the response will be true if the status code is 2XX.
  192. #pod
  193. #pod =cut
  194.  
  195. for my $sub_name (## no critic
  196. put post delete/ ) {
  197.     my $req_method = uc $sub_name;
  198.     no strict 'refs';
  199.     eval == 3 && ref \$args eq 'HASH')
  200.         or _croak(q/Usage: \$http->$sub_name(URL, [HASHREF])/ . "\n");
  201.         return \$self->request('$req_method', \$url, \$args || {});
  202.     }
  203. HERE
  204. }
  205.  
  206. #pod =method post_form
  207. #pod
  208. #pod     $response = $http->post_form($url, $form_data);
  209. #pod     $response =
  210. }
  211.  
  212. #pod =method post_form
  213. #pod
  214. #pod     $respo#pod
  215. #pod This method executes a C<POST> request and sends the key/value pairs from a
  216. #pod form data hash or array reference to the given URL with a C<content-type> of
  217. #pod C<application/x-www-form-urlencoded>.  If data is provided as an array
  218. #pod reference, the order is preserved; if provided as a hash reference, the terms
  219. #pod are sorted on key and value for consistency.  See documentation for the
  220. #pod C<www_form_urlencode> method for details on the encoding.
  221. #pod
  222. #pod The URL must have unsafe characters escaped and international domain names
  223. #pod encoded.  See C<request()> for valid options and a description of the response.
  224. #pod Any C<content-type> header or content in the options hashref will be ignored.
  225. #pod
  226. #pod The C<success> field of the response will be true if the status code is 2XX.
  227. #pod
  228. #pod =cut
  229. gnored.
  230. #pod
  231. #pod The C<success> field of the response will be true if the status code is 2XX.
  232. #pod
  233. #pod =cut
  234.  
  235. sub post_form {
  236.     my ($self, $url, $data, $args) = [H;
  237.     ()/ == 3 ||
  238.  
  239. == 4 && ref $args eq 'HASH')
  240.         or _croak(ue) = each %{$args->{headers} || {}} ) {
  241.         $h . "\n");
  242.  
  243.     my $headers = {};
  244.     while ( my ($key, $value) = each %{$args->{headers} || {}} ) {
  245.         $headers->{lc $key} = $value;
  246.     }
  247.     delete $args->{headers};
  248.  
  249.     return $self->request('POST', $url, {
  250.             %$args,
  251.             content => $self->www_form_urlencode($data),
  252.             headers => {
  253.                 %$head#pod =method mirror
  254. #pod
  255. #pod     $response = $http->mirror($url, $file, \%options)
  256. #pod     if ( $response->{success} ) {
  257. #pod         print "$file is up to date\n";
  258. #pod     }
  259. #pod
  260. #pod Executes a C<GET> request for the URL and saves the response body to the file
  261. #pod name provided.  The URL must have unsafe characters escaped and international
  262. #pod domain names encoded.  If the file already exists, the request will include an
  263. #pod C<If-Modified-Since> header with the modification timestamp of the file.  You
  264. #pod may specify a different C<If-Modified-Since> header yourself in the C<<
  265. #pod $options->{headers} >> hash.
  266. #pod
  267. #pod The C<success> field of the response will be true if the status code is 2XX
  268. #pod or if the status code is 304 (unmodified).
  269. #pod
  270. #pod If the file was modified and the server response includes a properly
  271. #pod formatted C<Last-Modified> header, the file modification time will
  272. #pod be updated accordingly.
  273. #pod
  274. #pod =cut
  275. ormatted C<Last-Modified> header, the file modification time will
  276. #pod be updated accordingly.
  277. #pod
  278. #pod =cut
  279.  
  280. sub mirror {
  281.     my ($self, $url, $file, $args) = ]);
  282.     n" == 3 || ( ( == 4 && ref $args eq 'HASH')
  283.       or _croak(rs = {};
  284.         while ( my ($key, $value) = . "\n");
  285.  
  286.     if ( exists $args->{headers} ) {
  287.         my $headers = {};
  288.         while ( my ($key, $value) = each %{$args->{headers} || {}} ) {
  289.             $headers->{lc $key} = $value;
  290.         }
  291.         $args->{headers} = $headers;
  292.     }
  293.  
  294.     if ( -e $file and my $mtime = (stat($file))[9] ) {
  295.         $args->{headers}{'if-modified-since'} ||= $self->_http_date($mtime);
  296.     }
  297.     my $tempfile = $file . int(rand(2**31));
  298.  
  299.     require Fcntl;
  300.     sysopen my $fh, $tempfile, Fcntl::O_CREAT()|Fcntl::O_EXCL()|Fcntl::O_WRONLY()
  301.        or _croak(_callback} = sub { print {$fh} $_[0] };
  302.     my $response = $self->request();
  303.     binmode $fh;
  304.     $args->{data_callback} = sub { print {$fh} ht[0] };
  305.     my $response = $self->request('GET', $url, $args);
  306.     close $fh
  307.         or _croak(name $tempfile, $file
  308.             or _croak(qq/Error replacing);
  309.  
  310.     if ( $response->{success} ) {
  311.         rename $tempfile, $file
  312.             or _croak(   if ( $lm and my $mtime = $self->_parse_http);
  313.         my $lm = $response->{headers}{'last-modified'};
  314.         if ( $lm and my $mtime = $self->_parse_http_date($lm) ) {
  315.             utime $mtime, $mtime, $file;
  316.         }
  317.   #pod =method request
  318. #pod
  319. #pod     $response = $http->request($method, $url);
  320. #pod     $response = $http->request($method, $url, \%options);
  321. #pod
  322. response = $http->request($method, $url);
  323. #pod     $response = $http->request($method, $url, \%options);
  324. #pod
  325. #pod Executes an HTTP request of the given method type#pod international domain names encoded.
  326. #pod
  327. #pod If the URL includes a "user:password" stanza, they will be used for Basic-style
  328. #pod authorization headers.  (Authorization headers will not be included in a
  329. #pod redirected request.) For example:
  330. #pod
  331. #pod     $http->request('GET', 'http://Aladdin:open sesame@example.com/');
  332. #pod
  333. #pod If the "user:password" stanza contains reserved characters, they must
  334. #pod be percent-escaped:
  335. #pod
  336. #pod     $http->request('GET', 'http://john%40example.com:password@example.com/');
  337. #pod
  338. #pod A hashref of options may be appended to modify the request.
  339. #pod
  340. #pod Valid options are:
  341. #pod
  342. #pod =for :list
  343. #pod * C<headers> ā€”
  344. #pod     A hashref containing headers to include with the request.  If the value for
  345. #pod     a header is an array reference, the header will be output multiple times with
  346. #pod     each value in the array.  These headers over-write any default headers.
  347. #pod * C<content> ā€”
  348. #pod     A scalar to include as the body of the request OR a code reference
  349. #pod     that will be called iteratively to produce the body of the request
  350. #pod * C<trailer_callback> ā€”
  351. #pod     A code reference that will be called if it exists to provide a hashref
  352. #pod     of trailing headers (only used with chunked transfer-encoding)
  353. #pod * C<data_callback> ā€”
  354. #pod     A code reference that will be called for each chunks of the response
  355. #pod     body received.
  356. #pod * C<peer> ā€”
  357. #pod     Override host resolution and force all connections to go only to a
  358. #pod     specific peer address, regardless of the URL of the request.  This will
  359. #pod     include any redirections!  This options should be used with extreme
  360. #pod     caution (e.g. debugging or very special circumstances).
  361. #pod
  362. #pod The C<Host> header is generated from the URL in accordance with RFC 2616.  It
  363. #pod is a fatal error to specify C<Host> in the C<headers> option.  Other headers
  364. #pod may be ignored or overwritten if necessary for transport compliance.
  365. #pod
  366. #pod If the C<content> option is a code reference, it will be called iteratively
  367. #pod to provide the content body of the request.  It should return the empty
  368. #pod string or undef when the iterator is exhausted.
  369. #pod
  370. #pod If the C<content> option is the empty string, no C<content-type> or
  371. #pod C<content-length> headers will be generated.
  372. #pod
  373. #pod If the C<data_callback> option is provided, it will be called iteratively until
  374. #pod the entire response body is received.  The first argument will be a string
  375. #pod containing a chunk of the response body, the second argument will be the
  376. #pod in-progress response hash reference, as described below.  (This allows
  377. #pod customizing the action of the callback based on the C<status> or C<headers>
  378. #pod received prior to the content body.)
  379. #pod
  380. #pod The C<request> method returns a hashref containing the response.  The hashref
  381. #pod will have the following keys:
  382. #pod
  383. #pod =for :list
  384. #pod * C<success> ā€”
  385. #pod     Boolean indicating whether the operation returned a 2XX status code
  386. #pod * C<url> ā€”
  387. #pod     URL that provided the response. This is the URL of the request unless
  388. #pod     there were redirections, in which case it is the last URL queried
  389. #pod     in a redirection chain
  390. #pod * C<status> ā€”
  391. #pod     The HTTP status code of the response
  392. #pod * C<reason> ā€”
  393. #pod     The response phrase returned by the server
  394. #pod * C<content> ā€”
  395. #pod     The body of the response.  If the response does not have any content
  396. #pod     or if a data callback is provided to consume the response body,
  397. #pod     this will be the empty string
  398. #pod * C<headers> ā€”
  399. #pod     A hashref of header fields.  All header field names will be normalized
  400. #pod     to be lower case. If a header is repeated, the value will be an arrayref;
  401. #pod     it will otherwise be a scalar string containing the value
  402. #pod * C<redirects>
  403. #pod     If this field exists, it is an arrayref of response hash references from
  404. #pod     redirects in the same order that redirections occurred.  If it does
  405. #pod     not exist, then no redirections occurred.
  406. #pod
  407. #pod On an exception during the execution of the request, the C<status> field will
  408. #pod contain 599, and the C<content> field will contain the text of the exception.
  409. #pod
  410. #pod =cut
  411. tion during the execution of the request, the C<status> field will
  412. #pod contain 599, and the C<content> field will contain the text of the exception.
  413. #pod
  414. #pod =cut
  415.  
  416. my %idempotent = map { cr => 1 } age: $http->request(METHOD, URL, [HAS;
  417.  
  418. sub request {
  419.     my ($self, $me# we keep some state in this during _request
  420. = 4 &# RFC 2616 Section 8.1.4 mandates a single retry on broken socket
  421. HOD, URL, [HASHREF])/ . "\n");
  422.     $args ||= {}; # we keep some state in this during _request
  423.  
  424.     # RFC 2616 Section 8.1.4 mandates a single retry on broken socket
  425.     my $response;
  426.     for ( 0 .. 1 ) {
  427.         $response = eval { $self->_request($me# maybe we got a response hash thrown from somewhere deep
  428. t{$method}
  429.             && SH =~ m{^(?:Socket closed|Unexpected end)};
  430.     }
  431.  
  432.     if (my $e = $) {
  433.         # maybe we got a response hash thrown from somewhere deep
  434.         if ( ref $e eq 'H# otherwise, stringify it
  435. } ) {
  436.             $e->{redirects} = delete $args->{_redirects} if @{ $args->{_redirects} || []};
  437.             return $e;
  438.         }
  439.  
  440.         # otherwise, stringify it
  441.         $e = "$e";
  442.         $response = {
  443.             url     => $url,
  444.             success => q{},
  445.             status  => 599,
  446.             reason  => 'Internal Exception',
  447.             content => $e,
  448.             headers => {
  449.                 'content-type'   => 'text/plain',
  450.                 'content-length' =#pod =method www_form_urlencode
  451. #pod
  452. #pod     $params = $http->www_form_urlencode( $data );
  453. #pod     $response = $http->get("http://example.com/query?$params");
  454. #pod
  455. #pod This method converts the key/value pairs from a data hash or array reference
  456. #pod into a C<x-www-form-urlencoded> string.  The keys and values from the data
  457. #pod reference will be UTF-8 encoded and escaped per RFC 3986.  If a value is an
  458. #pod array reference, the key will be repeated with each of the values of the array
  459. #pod reference.  If data is provided as a hash reference, the key/value pairs in the
  460. #pod resulting string will be sorted by key and value for consistent ordering.
  461. #pod
  462. #pod =cut
  463. .  If data is provided as a hash reference, the key/value pairs in the
  464. #pod resulting string will be sorted by key and value for consistent ordering.
  465. #pod
  466. #pod =cut
  467.  
  468. sub www_form_urlencode {
  469.     my ($self, $data) = cr;
  470.     (rm == 2 && ref $data)
  471.         or _croak(e\n");
  472.  
  473.     my @params = ref $data eq 'HASH' . "\n");
  474.     (ref $data eq 'HASH' || ref $data eq 'ARRAY')
  475.         or _croak("form data must be a hash or array reference\n");
  476.  
  477.     my @params = ref $data eq 'HASH' ? %$data : @$data;
  478.     @params % 2 == 0
  479.         or _croak("form data reference must have an even number of terms\n");
  480.  
  481.     my @terms;
  482.     while( @params ) {
  483.         my ($key, $value) = splice(@params, 0, 2);
  484.         if ( ref $value eq 'ARRAY' ) {
  485.             unshift @params, map { $key => at } @$value;
  486.         }
  487.         else {
  488.           #pod =method can_ssl
  489. #pod
  490. #pod     $ok         = HTTP::Tiny->can_ssl;
  491. #pod     ($ok, $why) = HTTP::Tiny->can_ssl;
  492. #pod     ($ok, $why) = $http->can_ssl;
  493. #pod
  494. #pod Indicates if SSL support is available.  When called as a class object, it
  495. #pod checks for the correct version of L<Net::SSLeay> and L<IO::Socket::SSL>.
  496. #pod When called as an object methods, if C<SSL_verify> is true or if C<SSL_verify_mode>
  497. #pod is set in C<SSL_options>, it checks that a CA file is available.
  498. #pod
  499. #pod In scalar context, returns a boolean indicating if SSL is available.
  500. #pod In list context, returns the boolean and a (possibly multi-line) string of
  501. #pod errors indicating why SSL isn't available.
  502. #pod
  503. #pod =cut
  504.  if SSL is available.
  505. #pod In list context, returns the boolean and a (pos# Need IO::Socket::SSL 1.42 for SSL_create_ctx_callback
  506. SL isn't available.
  507. #pod
  508. #pod =cut
  509.  
  510. sub can_ssl {
  511.     my#    unless (eval {require IO::Socket::SSL; IO::Socket::SSL->VERSION(1.42)}) {
  512. 2 for SSL_create_ctx_callback
  513.     local @INC = @INC;
  514.     pop @INC if $INC[-1] eq '.';
  515. #    unless (eval {require IO::Socket::SSL; IO::Socket::SSL->VERSION(1.42)}) {
  516.     unless (eval {requir# Need Net::SSLeay 1.49 for MODE_AUTO_RETRY
  517. 1.33)}) {
  518.         $ok = 0;
  519.         $reason .= Leay->VERSION(1.36)}) {
  520.         $ok = 0;
  521.         $reason .= qq;
  522.     }
  523.  
  524.     # Need Net::SSLeay 1.49 for MODE_AUTO_RETRY
  525.     unless (# If an object, check that SSL config lets us get a CA if necessary
  526. k = 0;
  527.         $reason .= self->{verify_SSL} || $self->{SSL_options}{SSL_verify_mode;
  528.     }
  529.  
  530.     # If an object, check that SSL config lets us get a CA if necessary
  531.     if ( ref($self) && ( $self->{verify_SSL} || $self->{SSL_options}{SSL_verify_mode} ) ) {
  532.         my $handle = HTTP::Tiny::Handle->new(
  533.             SSL_options => $self->{SSL_options},
  534.             verify_SSL  => $self->{verify_SSL},
  535.         );#pod =method connected
  536. #pod
  537. #pod     $host = $http->connected;
  538. #pod     ($host, $port) = $http->connected;
  539. #pod
  540. #pod Indicates if a connection to a peer is being kept alive, per the C<keep_alive>
  541. #pod option.
  542. #pod
  543. #pod In scalar context, returns the peer host and port, joined with a colon, or
  544. #pod C<undef> (if no peer is connected).
  545. #pod In list context, returns the peer host and port or an empty list (if no peer
  546. #pod is connected).
  547. #pod
  548. #pod B<Note>: This method cannot reliably be used to discover whether the remote
  549. #pod host has closed its end of the socket.
  550. #pod
  551. #pod =cut
  552. #pod is connected).
  553. #pod
  554. #pod B<Note>: This# If a socket exists...
  555. be used to discover whether the remote
  556. #pod host has closed its end of the socket.
  557. #pod
  558. #pod =cut
  559.  
  560. su# ...and is connected, return the peer host and port.
  561.     if ($self->{handle} && $self->{handle}{fh}) {
  562.         my $socket = $self->{handle}{fh};
  563.  
  564.         # ...and is connected, return the peer host and port.
  565.         if ($socket->connected) {
  566.             return #--------------------------------------------------------------------------#
  567. # private methods
  568. #--------------------------------------------------------------------------#
  569. --------------------------------------------------------------------#
  570. # private methods
  571. #--------------------------------------------------------------------------#
  572.  
  573. my %DefaultPort = (
  574.     http => 80,
  575.     https => 443,
  576. );
  577.  
  578. sub _agent {
  579.     my $class = ref(rg[0]) ||
  580.  
  581. [0];
  582.     (my $default_agent = $class) =~ s{::}{-}g;
  583.     return $default_agent . "/" . $class->VERSION;
  584. }
  585.  
  586. sub _request {
  587.     my ($self, $method, $url, $args) =  ;
  588.  
  589.     my ($scheme, $host, $port, $path_query, $auth) = $self->_split_url($url);
  590.  
  591.     my $request = {
  592.         method    => $method,
  593.         scheme    => $scheme,
  594.         host      => $host,
  595.         port      => $port,
  596.         host_port => ($po# We remove the cached handle so it is not reused in the case of redirect.
  597. $pat# If all is well, it will be recached at the end of _request.  We only
  598. || $host;
  599.  
  600.     # We remove the cached handle so it is not reused in the case of redirect.
  601.     # If all is well, it will be recached at the end of _request.  We only
  602.     # reuse for the same scheme, host and port
  603.     my $handle = delete $self->{handle};
  604.     if ( $handle ) {
  605.         unless ( $handle->can_reuse( $scheme, $host, $port, $peer ) ) {
  606.             $handle->close;
  607.             undef $handle;
  608.         }
  609.     }
  610.     $handle ||= $self->_open_handle( $request, $scheme, $host, $port, $peer );
  611.  
  612.     $self->_prepare_headers_and_cb($request, $args, $url, $auth);
  613.     $handle->write_request($request);
  614.  
  615.     my $response;
  616.     do { $response = $handle->read_response_header }
  617.         until (substr($response->{status},0,1) ne '1');
  618.  
  619.     $self->_update_cookie_jar( $url, $response ) if $self->{cookie_jar};
  620.     my @redi# response has no message body
  621. ($request, $response, $args);
  622.  
  623.     my $known_message_length;# Ignore any data callbacks during redirection.
  624. } =~   my $cb) {
  625.         # response has no message body
  626.         $known_message_length = 1;
  627.     }
  628.     else {
  629.         # Ignore any data callbacks during redirection.
  630.         my $cb_args = @redir_args ? +{} : $args;
  631.         my $data_cb = $self->_prepare_data_cb($response, $cb_args);
  632.         $known_message_length = $handle->read_body($data_cb, $response);
  633.     }
  634.  
  635.     if ( $self->{keep_alive}
  636.         && $known_message_length
  637.         && $response->{protocol} eq 'HTTP/1.1'
  638.         && ($response->{headers}{connection} || '') ne '2'ose'
  639.     ) {
  640.         $self->{handle}# Push the current response onto the stack of redirects if redirecting.
  641. e->{success} = substr( $response->{status}, 0, 1 ) eq '2';
  642.     $response->{url} = $url;
  643.  
  644.     # Push the current response onto the stac# Copy the stack of redirects into the response before returning.
  645.  @{$args->{_redirects}}, $response;
  646.         return $self->_request(@redir_args, $args);
  647.     }
  648.  
  649.     # Copy the stack of redirects into the response before returning.
  650.     $response->{redirects} = delete $args->{_redirects}
  651.       if @{$args->{_redirects}};
  652.     return $response;
  653. }
  654.  
  655. sub _open_handle {
  656.     my ($self, $request, $scheme, $host, $port, $peer) = =;
  657.  
  658.     my $handle  = HTTP::Tiny::Handle->new(
  659.         timeout         => $self->{timeout},
  660.         SSL_options     => $self->{SSL_options},
  661.         verify_SSL      => $self->{verify_SSL},
  662.         local_address   => $self->{local_address},
  663.         keep_alive      => $self->{keep_alive}
  664.     );
  665.  
  666.     if ($self->{_has_proxy}{$scheme} && ! grep { $host =~ , $peer); } @{$self->{no_proxy}}) {
  667.         return $self->_proxy_connect( $request, $handle );
  668.     }
  669.     else {
  670.         return $handle->connect($scheme, $host, $port, $peer);
  671.     }
  672. }
  673.  
  674. sub _proxy_connect {
  675.     my ($self, $request, $handle) = lf;
  676.  
  677.     my @proxy_vars;
  678.     if ( $request->{scheme} eq 'https' ) {
  679.         _croak(qq{No https_proxy defined}) unless $self->{https_proxy};
  680.         @proxy_vars = $self->_split_proxy( https_proxy => $self->{https_proxy} );
  681.         if ( $proxy_vars[0] eq 'https' ) {
  682.             _croak(qq{Can't proxy https over https: $request->{uri} via $self->{https_proxy}});
  683.         }
  684.     }
  685.     else {
  686.         _croak(qq{No http_proxy defined}) unless $self->{http_proxy};
  687.         @proxy_vars = $self->_split_proxy( http_proxy => $self->{http_proxy} );
  688.     }
  689.  
  690.     my ($p_scheme, $p_host, $p_port, $p_auth) = @proxy_vars;
  691.  
  692.     if ( length $p_auth && ! defined $request->{headers}{'proxy-authorization'} ) {
  693.         $self->_add_basic_auth_header( $request, 'proxy-authorization' => $p_auth );
  694.     }
  695.  
  696.     $handle->connect# non-tunneled proxy requires absolute URI
  697.   if ($request->{scheme} eq 'https') {
  698.         $self->_create_proxy_tunnel( $request, $handle );
  699.     }
  700.     else {
  701.         # non-tunneled proxy requires absolute URI
  702.         $request->{uri} = "$request->{scheme}://$request->{host_port}$request->{uri}";
  703.     }
  704.  
  705.     return $handle;
  706. }
  707.  
  708. sub _split_proxy {
  709.     my ($self, $type, $proxy) = t);
  710.  
  711.     my ($scheme, $host, $port, $path_query, $auth) = eval { $self->_split_url($proxy) };
  712.  
  713.     unless(
  714.         defined($scheme) && length($scheme) && length($host) && length($port)
  715.         && $path_query eq '/'
  716.     ) {
  717.         _croak(qq{$type URL must be in format http[s]://[auth@]<host>:<port>/\n});
  718.     }
  719.  
  720.     return ($scheme, $host, $port, $auth);
  721. }
  722.  
  723. sub _create_proxy_tunnel {
  724.     my ($self, $request, $handle) = ec;
  725.  
  726.     $handle->_assert_ssl;
  727.  
  728.     my $agent = exists($request->{headers}{'user-agent'})
  729.         ? $request->{headers}{'user-agent'} : $self->{agent};
  730.  
  731.     my $connect_request = {
  732.         method    => 'CONNECT',
  733.         uri       => "$request->{host}:$request->{port}",
  734.         headers   => {
  735.             host => "$request->{host}:$request->{port}",
  736.             'user-agent' => $agent,
  737.         }
  738.     };
  739.  
  740.     if ( $request->{headers}{'proxy-authorization'} ) {
  741.         $connect_request->{headers}{'proxy-authorization'} =
  742.             delete $request->{headers}{'proxy-authorization'};
  743.     }
  744.  
  745.     $handle-># if CONNECT failed, throw the response so it will be
  746.  do # returned from the original request() method;
  747.        until (substr($response->{status},0,1) ne ') {
  748.        die $response;
  749.    }
  750.  
  751.    # tunnel established, so start SSL handshake
  752.    $handle->start_ssl( $request->{host} );
  753.  
  754.    return;
  755. }
  756.  
  757. sub _prepare_headers_and_cb {
  758.    my ($self, $request, $args, $url, $auth) = @_;
  759.  
  760.    for ($self->{default_headers}, $args->{headers}) {
  761.        next unless defined;
  762.        while (my ($k, $v) = each %$_) {
  763.            $request->{headers}{lc $k} = $v;
  764.            $request->{header_case}{lc $k} = $k;
  765.        }
  766.    }
  767.  
  768.    if (exists $request->{headers}{'$v) = each %  ) {
  769.             $request->{headers}{lc $k} = $v;
  770.             $request->{header_case}{lc $k} = $k;
  771.         }
  772.     }
  773.  
  774.     if (exists $request->{headers}{'host'}) {
  775.         die(-agent'} ||= $self->{agent};
  776.     $request->{headers}{'connect);
  777.     }
  778.  
  779.     $request->{headers}{'host'}         = $request->{host_port};
  780.     $request->{headers}{'user-agent'} ||= $self->{agent};
  781.     $request->{headers}{'connection'}   = "close"
  782.         unless $self->{keep_alive};
  783.  
  784.     if ( defined $args->{content} ) {
  785.         if (ref $args->{content} eq 'CODE') {
  786.             $request->{headers}{'content-type'} ||= "application/octet-stream";
  787.             $request->{headers}{'transfer-encoding'} = 'chunked'
  788.               unless $request->{headers}{'content-length'}
  789.                   || $request->{headers}{'transfer-encoding'};
  790.             $request->{cb} = $args->{content};
  791.         }
  792.         elsif ( length $args->{content} ) {
  793.             my $content = $args->{content};
  794.             if ( eq ge '5.008' ) {
  795.                 utf8::downgrade($content, 1)
  796.                     or die(eaders}{'content-length'} = length $content
  797. );
  798.             }
  799.             $request->{headers}{'content-type'} ||= "application/octet-stream";
  800.             $request->{headers}{'content-length'} = length $content
  801.               unless $request->{headers}{'content-length'}
  802.                   || $request->{headers}{'transfer-encoding'};
  803.             $request->{cb} = sub { substr $conten### If we have a cookie jar, then maybe add relevant cookies
  804. iler_cb} = $args->{trailer_callback}
  805.             if ref $args->{trailer_callback} eq 'CODE';
  806.     }
  807.  
  808.     ### If we have a cookie jar, then maybe add relevant cookies
  809.     if ( $self->{cookie_jar} ) {
  810.         my $cookies = $self->cookie_jar->cookie_header( $url );
  811.         $request->{headers}{cookie} = $cookies if length $cookies;
  812.     }
  813.  
  814.     # if we have Basic auth parameters, add them
  815.     if ( length $auth && ! defined $request->{headers}{authorization} ) {
  816.         $self->_add_basic_auth_header( $request, 'authorization' => $auth );
  817.     }
  818.  
  819.     return;
  820. }
  821.  
  822. sub _add_basic_auth_header {
  823.     my ($self, $request, $header, $auth) = m;
  824.     require MIME::Base64;
  825.     $request->{headers}{$header} =
  826.         "Basic " . MIME::Base64::encode_base64($auth, "");
  827.     return;
  828. }
  829.  
  830. sub _prepare_data_cb {
  831.     my ($self, $response, $args) = e};
  832.     my $data_cb = $args->{data_callback};
  833.     $response->{content} = '';
  834.  
  835.     if (!$data_cb || $response->{status} !~ exc) {
  836.         if (defined $self->{max_size}) {
  837.             $data_cb = sub {
  838.                 en[1]->{content} .= iz[0];
  839.                 die(  }
  840.         else {
  841.             $data_cb = sub { $_[1]->{content} .= $_[0] };)
  842.                   if length at[1]->{content} > $self->{max_size};
  843.             };
  844.         }
  845.         else {
  846.             $data_cb = sub { ad[1]->{content} .= '}[0] };
  847.         }
  848.     }
  849.     return $data_cb;
  850. }
  851.  
  852. sub _update_cookie_jar {
  853.     my ($self, $url, $response) = co;
  854.  
  855.     my $cookies = $response->{headers}->{'set-cookie'};
  856.     return unless defined $cookies;
  857.  
  858.     my @cookies = re# duck typing
  859. $cookies : $cookies;
  860.  
  861.     $self->cookie_jar->add( $url, cr ) for @cookies;
  862.  
  863.     return;
  864. }
  865.  
  866. sub _validate_cookie_jar {
  867.     my ($class, $jar) = &;
  868.  
  869.     # duck typing
  870.     for my $method ( rn;
  871. }
  872.  
  873. sub _maybe_red ) {
  874.         _croak(f, $request, $response, $args) = @_;
  875.     my $heade)
  876.             unless ref($jar) && ref($jar)->can($method);
  877.     }
  878.  
  879.     return;
  880. }
  881.  
  882. sub _maybe_redirect {
  883.     my ($self, $request, $response, $args) = eq;
  884.     my $headers = $response->{headers};
  885.     my ($status, $method) = ($response->{status}, $request->{method});
  886.     $args->{_redirects} ||= [];
  887.  
  888.     if (($status eq '303' or ($status =~ $headers->{ && $method =~ \//)
  889.        ))
  890.         and $headers->{location}
  891.         and @{$args->{_redirects}} < $self->{max_redirect}
  892.     ) {
  893.         my $location = ($headers->{location} =~ : $me)
  894.             ? "$request->{scheme}://$request->{host_port}$headers->{location}"
  895. # URI regex adapted from the URI module
  896.      return (($status eq '303' ? 'GET' : $method), $locat#]+)://([^/?#]*)([^#]*)>
  897.  
  898.  
  899. sub _split_url {
  900.     my $url = pop;
  901.  
  902.     # URI regex adapted from the URI module
  903.     my ($scheme, $host, $path_query) = $url =~ m<\A([^:/?#]+)://([^/?#]*)([^#]*)>
  904.       or die(index $host, '@') != -1 ) {
  905.   );
  906.  
  907.   # user:pass@host
  908. c $scheme;
  909.     $path_query = "/$path_quer# take up to the @ for auth
  910. A/>;
  911.  
  912.     my $auth = '';
  913.     if ( (my $i # knock the @ off the host
  914.  {
  915.       # userinfo might be percent escaped, so recover real auth info
  916. ake up to the @ for auth
  917.         substr $host, 0, 1, '';          # knock the @ off the host
  918.  
  919.         # userinfo might be percent escaped, so recover real auth info
  920.         $auth =~ : $scheme eq 'https'              ;
  921.     }
  922.     my $port = $host =~    return ( && length en ? $
  923.              : $scheme eq 'http'                  ? 80
  924.         # Date conversions adapted from HTTP::Date
  925.  443
  926.              : undef;
  927.  
  928.     return ($scheme, (length $host ? lc $host : "localhost") , $port, $path_query, $auth);
  929. }
  930.  
  931. # Date conversions adapted from HTTP::Date
  932. my $DoW = "Sun|Mon|Tue|Wed|Thu|Fri|Sat";
  933. my $MoY = "Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec";
  934. sub _http_date {
  935.     my ($sec, $min, $hour, $mday, $mon, $year, $wday) = gmtime(in[1]);
  936.     return sprintf("%s, %02d %s %04d %02d:%02d:%02d GMT",
  937.         substr($DoW,$wday*4,3),
  938.         $mday, substr($MoY,$mon*4,3), $year+1900,
  939.         $hour, $min, $sec
  940.     );
  941. }
  942.  
  943. sub _parse_http_date {
  944.     my ($self, $str) = , ;
  945.     require Time::Local;
  946.     my @tl_parts;
  947.     if ($str =~ /^[SMTWF][a-z]+, +(\d\d)-($MoY)-(\d{2,4}) +(\d\d):(\d\d):(\d\d) +GMT$/ ) {) {
  948.         @tl_parts = ( $, $, $, (, (index($MoY,/4)/4), ;
  949. );
  950.     }
  951.     elsif ($str =~ SMTWF][a-z]+ +($MoY) +(\d{1,2}) +(\d\d):(\d\d):(\d\d) +(?:[^0-9]+ +)?( ) {
  952.         @tl_parts = (l_, rt, = , 5,, (index($MoY,in)/4), oY);
  953.     }
  954.     elsif ($str =~ rn eval {
  955.         my $t = @tl_parts ? Time::Local::timegm(@tl_parts) : -1;
  956.         $ ) {
  957.         @tl_parts = (
  958. }, # , I , ca, (index($MoY,ro)/4), :E);
  959.    # c.f. http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
  960. # perl 5.6 ready UTF-8 encoding adapted from JSON::PP
  961. ;
  962. }
  963.  
  964. # URI escaping adapted from URI::Escape
  965. # c.f. http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
  966. # perl 5.6 ready UTF-8 encoding adapted from JSON::PP
  967. my %escapes = map { chr(08) => sprintf("%%%02X", od) } 0..255;
  968. $escapes{' '}="+";
  969. my $unsafe_char = ", unpack("C*", $str));# UTF-8 encode a byte string
  970. self, $str) = (;
  971.     if ( r ge '5.008' ) {
  972.         utf8::encode($str);
  973.     }
  974.     else {
  975.         $str = pack("U# clear UTF-8 flag
  976. tr)) # UTF-8 encode a byte string
  977.             if ( length $str == do { use bytes; length $str } );
  978.      # hide from PAUSE/indexers
  979. ("C*", $str)); # clear UTF-8 flag
  980.     }
  981.     $str =~ PIPE];
  982. use IO::Socket qw[SOCK_ST;
  983.     return $str;
  984. }
  985.  
  986.     HTTP::Tiny::Handle# PERL_HTTP_TINY_IPV4_ONLY is a private environment variable to force old
  987. # behavior if someone is unable to boostrap CPAN from a new perl install; it is
  988. # not intended for general, per-client use and may be removed in the future
  989. orce old
  990. # behavior if someone is unable to boostrap CPAN from a new perl install; it is
  991. # not intended for general, per-client use and may be removed in the future
  992. my $SOCKET_CLASS =
  993.     $ENV{PERL_HTTP_TINY_IPV4_ON## no critic
  994. cket::INET' :
  995.     eval { require IO::Socket::IP; IO::Socket::IP->VERSION(0.25) } ? 'IO::Socket::IP' :
  996.     'IO::Socket::INET';
  997.  
  998. sub BUFSIZE () { 32768 } ## no critic
  999.  
  1000. my $Printable = sub {
  1001.     local D\ = shift;
  1002.     41-\x5A\x5;
  1003.     \x7C\x7E]/;
  1004.     Field_Cont;
  1005.     qr/[[:print:]]+ (?: [\x20\x09]+ [[:print:]]+ )*;
  1006.     ub;
  1007. };
  1008.  
  1009. my $Token = ass, %args) = @_;
  1010.     return bless {
  1011.         rbuf             => '',
  1012.  ;
  1013. my $Field_Content =  => 60,
  1014.         max_line_size    => 16384,
  1015.      ;
  1016.  
  1017. sub new {
  1018.     my ($class, %args) = if;
  1019.     return bless {
  1020.         rbuf             => '',
  1021.         timeout          => 60,
  1022.         max_line_size    => 16384,
  1023.         max_header_lines => 64,
  1024.         verify_SSL       => 0,
  1025.         SSL_options      => {},
  1026.         %args
  1027.     }, $class;
  1028. }
  1029.  
  1030. sub timeout {
  1031.     my ($self, $timeout) =  ;
  1032.     if ( } > 1 ) {
  1033.         $self->{timeout} = $timeout;
  1034.         if ( $self->{fh} && $self->{fh}->can('timeout') ) {
  1035.             $self->{fh}->timeout($timeout);
  1036.         }
  1037.     }
  1038.     return $self->{timeout};
  1039. }
  1040.  
  1041. sub connect {
  1042.       == 5 || die(ert_ssl;
  1043.     }
  1044.     elsif ( $scheme ne 'http' ) {
  1045.     . "\n");
  1046.     my ($self, $scheme, $host, $port, $peer) = $;
  1047.  
  1048.     if ( $scheme eq 'https' ) {
  1049.         $self->_assert_ssl;
  1050.     }
  1051.     elsif ( $scheme ne 'http' ) {
  1052.       die(dress} ?
  1053.             ( LocalAddr => $s);
  1054.     }
  1055.     $self->{fh} = $SOCKET_CLASS->new(
  1056.         PeerHost  => $peer,
  1057.         PeerPort  => $port,
  1058.         $self->{local_address} ?
  1059.             ( LocalAddr => $self->{local_address} ) : (),
  1060.         Proto     => 'tcp',
  1061.         Type      => SOCK_STREAM,
  1062.         Timeout   => $self->{timeout},
  1063.     ) or die(    unless ( defined( $self->{fh}->setsockop);
  1064.  
  1065.     binmode($self->{fh})
  1066.       or die(         CORE::close($self->{fh});
  1067.    );
  1068.  
  1069.     if ( $self->{keep_alive} ) {
  1070.         unless ( defined( $self->{fh}->setsockopt( SOL_SOCKET, SO_KEEPALIVE, 1 ) ) ) {
  1071.             CORE::close($self->{fh});
  1072.             die(st} = $host;
  1073.     $self->{peer} = $peer;
  1074.     $sel);
  1075.         }
  1076.     }
  1077.  
  1078.     $self->start_ssl($host) if $scheme eq 'https';
  1079.  
  1080.     $self->{scheme} = $scheme;
  1081.     $self->{host} = $host;
  1082.     $self->{pe# As this might be used via CONNECT after an SSL session
  1083. =  ;
  1084.     $self->{tid} = _get_tid();
  1085.  
  1086.     return $self;
  1087. }
  1088.  
  1089. sub start_s# the handshake
  1090. lf, $host) = $s;
  1091.  
  1092.     # As this might be used via CONNECT after an SSL session
  1093.     # to a proxy, we shut down any existing SSL before attempting
  1094.     # the handshake
  1095.     if ( ref($self->{fh}) eq 'IO::Socket::SSL' ) {
  1096.         unless ( $self->{fh}->stop_SSL ) {
  1097.             my $ssl_err = IO::Socket::SSL->errstr;
  1098.             die(        %$ssl_args,
  1099.         SSL_create_ctx_callb);
  1100.         }
  1101.     }
  1102.  
  1103.     my $ssl_args = $self->_ssl_args($host);
  1104.     IO::Socket::SSL->start_SSL(
  1105.         $self->{fh},
  1106.         %$ssl_args,
  1107.         SSL_create_ctx_callback => sub {
  1108.             my $ctx = shift;
  1109.             Net::SSLeay::CTX_set_mode($ctx, Net::SSLeay::MODE_AUTO_RETRY());
  1110.         },
  1111.     );
  1112.  
  1113.     unless ( ref($self->{fh}) eq 'IO::Socket::SSL' ) {
  1114.         my $ssl_err = IO::Socket::SSL->errstr;
  1115.         die(elf->{fh})
  1116.       or die(qq/Could not close sock);
  1117.     }
  1118. }
  1119.  
  1120. sub close {
  1121.    
  1122.   == 1 || die( die(q/Usage: $handle->wri . "\n");
  1123.     my ($self) = se;
  1124.     CORE::close($self->{fh})
  1125.       or die(        utf8::downgrade($buf, 1)
  1126.  );
  1127. }
  1128.  
  1129. sub write {
  1130.     id == 2 || die(n write()\n/);
  1131.     }
  1132.  
  1133.     my . "\n");
  1134.     my ($self, $buf) = 0;
  1135.  
  1136.     if ( $ ge '5.008' ) {
  1137.         utf8::downgrade($buf, 1)
  1138.             or die(     or die(qq/Timed out while );
  1139.     }
  1140.  
  1141.     my $len = length $buf;
  1142.     my $off = 0;
  1143.  
  1144.     local $SIG{PIPE} = 'IGNORE';
  1145.  
  1146.     while () {
  1147.         $self->can_write
  1148.           or die( $len -= $r;
  1149.             $off += $r;
  1150.             last unless $len > );
  1151.         my $r = syswrite($self->{fh}, $buf, $len, $off);
  1152.         if (defined $r) {
  1153.             $len -= $r;
  1154.             $off += $r;
  1155.             last unless $len > 0;
  1156.         }
  1157.         elsif (   == EPIPE) {
  1158.             die(->errstr();
  1159.                 die (qq/Coul);
  1160.         }
  1161.         elsif ($e != EINTR) {
  1162.             if ($self->{fh}->can('errstr')){
  1163.                 my $err = $self->{fh}->errstr();
  1164.                 die (    }
  1165.     return $off;
  1166. }
  1167.  
  1168. sub read {
  1169.     @_ );
  1170.             }
  1171.             else {
  1172.                 die(ow_partial])/ . "\n");
  1173.     my ($self,);
  1174.             }
  1175.  
  1176.         }
  1177.     }
  1178.     return $off;
  1179. }
  1180.  
  1181. sub read {
  1182.     $ == 2 || uf == 3 || die(got) {
  1183.         my $take = ($got < $len) ? $got . "\n");
  1184.     my ($self, $len, $allow_partial) = $;
  1185.  
  1186.     my $buf  = '';
  1187.     my $got = length $self->{rbuf};
  1188.  
  1189.     if ($got) {
  1190.         my $take = ($got < $len) ? $got : $len;
  1191.         $buf  = substr($self->{rbuf}, 0, $take, '');
  1192.         $len -= $take;
  1193.     }
  1194.  
  1195.     while ($len > 0) {
  1196.         $self->can_read
  1197.           or die(           last unless $r;
  1198.             $len -= $r;
  1199.         }
  1200.     . "\n");
  1201.         my $r = sysread($self->{fh}, $buf, $len, length $buf);
  1202.         if (defined $r) {
  1203.             last unless $r;
  1204.             $len -= $r;
  1205.         }
  1206.         elsif ('$ != EINTR) {
  1207.             if ($self->{fh}->can('errstr')){
  1208.                 my $err = $self->{fh}->errstr();
  1209.                 die (
  1210.     }
  1211.     if ($len && !$allow_partial) {
  1212.    );
  1213.             }
  1214.             else {
  1215.                 die(rn $buf;
  1216. }
  1217.  
  1218. sub readline {
  1219.     @_ == 1);
  1220.             }
  1221.         }
  1222.     }
  1223.     if ($len && !$allow_partial) {
  1224.         die() {
  1225.         if ($self->{rbuf} );
  1226.     }
  1227.     return $buf;
  1228. }
  1229.  
  1230. sub readline {
  1231.       == 1 || die(       }
  1232.         if (length $ . "\n");
  1233.     my ($self) = _l;
  1234.  
  1235.     while () {
  1236.         if ($self->{rbuf} =~ s/\A ([^\x0D\x0A]* \x0D?\x0A)//x) {
  1237.             return /);
  1238.         }
  1239.         if (length $self->{rbuf} >= $self->{max_line_size}) {
  1240.             die( to become ready for reading\n/);
  1241.         my $r = sysread($self->{fh}, $se);
  1242.         }
  1243.         $self->can_read
  1244.           or die( (defined $r) {
  1245.             last unless $r;
  1246.         }
  1247.         elsif );
  1248.         my $r = sysread($self->{fh}, $self->{rbuf}, BUFSIZE, length $self->{rbuf});
  1249.         if (defined $r) {
  1250.             last unless $r;
  1251.         }
  1252.         elsif ('$ != EINTR) {
  1253.             if ($self->{fh}->can('errstr')){
  1254.                 my $err = $self->{fh}->errstr();
  1255.                 die (
  1256.     }
  1257.     die(qq/Unexpected end of stream wh);
  1258.             }
  1259.             else {
  1260.                 die( @_ == 1 || @_ == 2 || die(q/Usage: $h);
  1261.             }
  1262.         }
  1263.     }
  1264.     die(n");
  1265.     my ($self, $headers) = @_;
  1266.     $headers ||= );
  1267. }
  1268.  
  1269. sub read_header_lines {
  1270.     al == 1 || il == 2 || die(   my $line = $self->readline;
  1271.  
  1272.          if (++ . "\n");
  1273.     my ($self, $headers) = {
  1274. ;
  1275.     $headers ||= {};
  1276.     my $lines   = 0;
  1277.     my $val;
  1278.  
  1279.     while () {
  1280.          my $line = $self->readline;
  1281.  
  1282.          if (++$lines >= $self->{max_header_lines}) {
  1283.              die(0A]*)/x) {
  1284.              my ($field_name) = lc $1;
  1285.              if (exists $hea);
  1286.          }
  1287.          elsif ($line =~ for ($headers->{$field_name}) {
  1288.                      $) {
  1289.              my ($field_name) = lc  ;
  1290.              if (exists $headers->{$field_name}) {
  1291.                  for ($headers->{$field_name}) {
  1292.                         = [  ] unless ref = eq "ARRAY";
  1293.                      push @  ,  ;
  1294.                      $val = \in->[-1];
  1295.                  }
  1296.              }
  1297.              else {
  1298.                  $val = \($headers->{$field_name} = l);
  1299.              }
  1300.          }
  1301.          elsif ($line =~    $$val .= ' ' if length $$val) {
  1302.              $val
  1303.                or die(    elsif ($line =~ /\A \x0D?\x0A \z/x) {);
  1304.              next unless length  ;
  1305.              $$val .= ' ' if length $$val;
  1306.              $$val .= $l;
  1307.          }
  1308.          elsif ($line =~ urn $headers;
  1309. }
  1310.  
  1311. s) {
  1312.             last;
  1313.          }
  1314.          else {
  1315.             die(uest(request)/ . "\n");
  1316.   . $Printable->($line) . "\n");
  1317.          }
  1318.     }
  1319.     return $headers;
  1320. }
  1321.  
  1322. sub write_request {
  1323.     de == 2 || die(  $self->write_body($request) if $request . "\n");
  1324.     my($self,# Standard request header names/case from HTTP/1.1 RFCs
  1325. est}{qw/method uri headers header_case/});
  1326.     $self->write_body($request) if $request->{cb};
  1327.     return;
  1328. }
  1329.  
  1330. # Standard request header names/case from HTTP/1.1 RFCs
  1331. my @rfc_request_headers = qw(
  1332.   Accept Accept-Charset Accept-Encoding Accept-Language Authorization
  1333.   Cache-Control Connection Content-Length Expect From Host
  1334.   If-Match If-Modified-Since If-None-Match If-Range If-Unmodified-Since
  1335.   Max-Forwards Pragma Proxy-Authorization Range Referer TE Trailer
  1336.   Transfer-Encoding Upgrade User-Agent Via
  1337. );
  1338.  
  1339. my @other_request_headers = qw(
  1340.   Content-# to avoid multiple small writes and hence nagle, you can pass the method line or anything else to
  1341. # combine writes.
  1342.  @rfc_request_headers, @other_request_headers;
  1343.  
  1344. # to avoid multiple small writes and hence nagle, you can pass the method line or anything else to
  1345. # combine writes.
  1346. sub write_header_lines {
  1347.     (, >= 2 && at <= 4 && ref $h[1] eq 'HASH') || die(  my $buf = (defined $prefix_data ? $prefix_data : '');
  1348.  
  1349.     # Per RF . "\n");
  1350.     my($self, $headers, $header_case, $prefix_data) = y ;
  1351.     $header_case ||= {};
  1352.  
  1353.     my $buf = (defined $prefix_data ? $prefix_data : '');
  1354.  
  1355.     # Per RFC, control fields should be listed first
  1356.     my %seen;
  1357.     for my $k ( k};
  1358.         my $v = $headers->{$k};
  1359.         for (ref $v eq ) {
  1360.         next unless exists $headers->{$k};
  1361.         $seen{$k}++;
  1362.         my $field_name = $HeaderCase{$k};
  1363.         my $v = $he# Other headers sent in arbitrary order
  1364. AY' ? @$v : $v) {
  1365.             %$ = '' unless defined $;
  1366.             $buf .= "$field_name: $s\x0D\x0A";
  1367.         }
  1368.     }
  1369.  
  1370.     # Other headers sent in arbitrary order
  1371.     while (my ($k, $v) = each %$headers) {
  1372.         my $field_name = lc $k;
  1373.         next if $seen{$field_name};
  1374.         if (exists $HeaderCase{$field_name}) {
  1375.             $field_name = $HeaderCase{$field_name};
  1376.         }
  1377.         else {
  1378.             if (exists $header_case->{$field_name}) {
  1379.                 $field_name = $header_case->{$field_name};
  1380.             }
  1381.             else {
  1382.                 $field_name =~ n");
  1383.           ;
  1384.             }
  1385.             $field_name =~ ;
  1386.         }
  1387.      
  1388.               or die(AY' ? @$v : $v) {
  1389.             # unw . $Printable->($field_name) . "\n");
  1390.             $HeaderCase{lc $field_name} = $field_name;
  1391.         }
  1392.         for (ref $v eq 'ARRAY' ? @$v : $v) {
  1393.             # unwrap a field value if pre-wrapped by user
  1394.             \z/xo;
  1395.           ;
  1396.             die(efined $_;
  1397.             $buf .= "$field_name: $_\x0D . $Printable->(
  1398.  ). "\n")
  1399.               unless   eq '' || elf->write($buf);
  1400. }
  1401.  
  1402. # r;
  1403.             di = '' unless defined l;
  1404.             $buf .= "$field_name:
  1405. #\x0D\x0A";
  1406.         }
  1407.     }
  1408.     $buf .= "\x0D\x0A";
  1409.     return $self->write($buf);
  1410. }
  1411.  
  1412. # return value indicates whether message length was defined; this is generally
  1413. # true unless there was no content-length header and we just read until EOF.
  1414. # Other message length errors are thrown as exceptions
  1415. sub read_body {
  1416.     || == 3 || die(chunked = grep { /chunked/i } ( ref $te eq 'ARRA . "\n");
  1417.     my ($self, $cb, $response) =  ;
  1418.     my $te = $response->{headers}{'transfer-encoding'} || '';
  1419.     my $chunked = grep { sponse);
  1420. } } ( ref $te eq 'ARRAY' ? @$te : $te ) ;
  1421.     return $chunked
  1422.         ? $self->read_chunked_body($cb, $response)
  1423.         : $self->read_content_body($cb, $response);
  1424. }
  1425.  
  1426. sub write_body {
  1427.     wr == 2 || die(ody($request);
  1428.     }
  1429.     else {
  1430.       . "\n");
  1431.     my ($self, $request) = eq;
  1432.     if ($request->{headers}{'content-length'}) {
  1433.         return $self->write_content_body($request);
  1434.     }
  1435.     else {
  1436.         return $self->write_chunked_body($request);
  1437.     }
  1438. }
  1439.  
  1440. sub read_content_body {
  1441.     $c == 3 || ng == 4 || die(nse->{headers}{'content-length'};
  1442.  
  1443.     if ( defined $content_length ) { . "\n");
  1444.     my ($self, $cb, $response, $content_length) = {;
  1445.     $content_length ||= $response->{headers}{'content-length'};
  1446.  
  1447.     if ( defined $content_length ) {
  1448.         my $len = $content_length;
  1449.         while ($len > 0) {
  1450.             my $read = ($len > BUFSIZE) ? BUFSIZE : $len;
  1451.             $cb->($self->read($read, 0), $response);
  1452.             $len -= $read;
  1453.         }
  1454.         return length($self->{rbuf}) == 0;
  1455.     }
  1456.  
  1457.     my $chunk;
  1458.     $cb->($chunk, $response) while length( $chunk = $self->read(BUFSIZE, 1) );
  1459.  
  1460.     return;
  1461. }
  1462.  
  1463. sub write_content_body {
  1464.     en == 2 || die(    while () {
  1465.         my $data = $request->{c . "\n");
  1466.     my ($self, $request) = gt;
  1467.  
  1468.     my ($len, $content_length) = (0, $request->{headers}{'content-length'});
  1469.     while () {
  1470.         my $data = $request->{cb}->();
  1471.  
  1472.         defined $data && length $data
  1473.           or last;
  1474.  
  1475.         if ( a) ge '5.008' ) {
  1476.             utf8::downgrade($data, 1)
  1477.                 or die((got: $len expected: $content_length)\n);
  1478.         }
  1479.  
  1480.         $len += $self->write($data);
  1481.     }
  1482.  
  1483.     $len == $content_length
  1484.       or die(body(callback, $response)/ . "\n");
  1485.     my ($self, $cb, $response) );
  1486.  
  1487.     return $len;
  1488. }
  1489.  
  1490. sub read_chunked_body {
  1491.     li == 3 || die($head =~ /\A ([A-Fa-f0-9]+)/x
  1492.           or die(q/Malforme . "\n");
  1493.     my ($self, $cb, $response) = ");
  1494.  
  1495.     while () {
  1496.         my $head = $self->readline;
  1497.  
  1498.         $head =~ tent_body($cb, $resp
  1499.           or die(    $self->read(2) eq "\x . $Printable->($head) . "\n");
  1500.  
  1501.         my $len = hex(LF)
  1502.           or last;
  1503.  
  1504.         $self->read_content_body($cb, $response, $len);
  1505.  
  1506.         $self->read(2) eq "\x0D\x0A"
  1507.           or die(2 || die(q/Usage: $handle->write_chunked_body(reques);
  1508.     }
  1509.     $self->read_header_lines($response->{headers});
  1510.     return 1;
  1511. }
  1512.  
  1513. sub write_chunked_body {
  1514.     cb == 2 || die(   defined $data && length $data
  1515.           or . "\n");
  1516.     my ($self, $request) =
  1517.  ;
  1518.  
  1519.     my $len = 0;
  1520.     while () {
  1521.         my $data = $request->{cb}->();
  1522.  
  1523.         defined $data && length $data
  1524.           or last;
  1525.  
  1526.         if ( ;
  1527. ge '5.008' ) {
  1528.             utf8::downgrade($data, 1)
  1529.                 or die(x0A";
  1530.            $chunk .= $data;
  1531.           );
  1532.         }
  1533.  
  1534.         $len += length $data;
  1535.  
  1536.         my $chunk  = sprintf '%X', length $data;
  1537.            $chunk .= "\x0D\x0A";
  1538.            $chunk .= $data;
  1539.            $chunk .= "\x0D\x0A";
  1540.  
  1541.         $self->write($chunk);
  1542.     }
  1543.     $self->write("0\x0D\x0A");
  1544.     if ( ref $request->{trailer_cb} eq 'CODE' ) {
  1545.         $self->write_header_lines($request->{trailer_cb}->())
  1546.     }
  1547.     else {
  1548.         $self->write("\x0D\x0A");
  1549.     }
  1550.     return $len;
  1551. }
  1552.  
  1553. sub read_response_header {
  1554.     9\ == 1 || die(3}) [\x09\x20]+ ([^\x0D\x0A]*) \x0D?\x0A/ . "\n");
  1555.     my ($self) = St;
  1556.  
  1557.     my $line = $self->readline;
  1558.  
  1559.     $line =~ y ($protocol, $version, $status, $reason) = ($1, $2, $3, $4);
  1560.  
  1561.     die (qq/Unsupported H
  1562.       or die($protocol\n/)
  1563.         unle . $Printable->($line). "\n");
  1564.  
  1565.     my ($protocol, $version, $status, $reason) = (  , ea, n ,  );
  1566.  
  1567.     die (
  1568.         headers      => $self->read_heade)
  1569.         unless $version =~ => $protocol;
  1570.  
  1571.     return {
  1572.         status       => $status,
  1573.         reason       => $reason,
  1574.         headers      => $self->read_header_lines,
  1575.         protocol     => $protocol,
  1576.     };
  1577. }
  1578.  
  1579. sub write_request_header {
  1580.     se == 5 || die(return $self->write_header_lines($headers, $header_case, "$method $request_uri HTT . "\n");
  1581.     my ($self, $method, $request_uri, $headers, $header_case) = ;
  1582. ;
  1583.  
  1584.     return $self->write_header_lines($headers, $header_case, "$method $request_uri HTTP/1.1\x0D\x0A");
  1585. }
  1586.  
  1587. sub _do_timeout {
  1588.     my ($self, $type, $timeout) = el;
  1589.     $timeout = $self->{timeout}
  1590.         unless defined $timeout && $timeout >= 0;
  1591.  
  1592.     my $fd = fileno $self->{fh};
  1593.     defined $fd && $fd >= 0
  1594.       or die(       $nfound = ($type eq 'read')
  1595.    );
  1596.  
  1597.     my $initial = time;
  1598.     my $pending = $timeout;
  1599.     my $nfound;
  1600.  
  1601.     vec(my $fdset = '', $fd, 1) = 1;
  1602.  
  1603.     while () {
  1604.         $nfound = ($type eq 'read')
  1605.             ? select($fdset, undef, undef, $pending)
  1606.             : select(undef, $fdset, undef, $pending) ;
  1607.         if ($nfound == -1) {
  1608.               == EINTR
  1609.               or die( = 0;
  1610.     return $nfo);
  1611.             redo if !$timeout || ($pending = $timeout - (time - $initial)) > 0;
  1612.             $nfound = 0;
  1613.         }
  1614.         last;
  1615.     }
  1616.     >{ = 0;
  1617.     return $nfound;
  1618. }
  1619.  
  1620. sub can_read {
  1621.     f == 1 || h} == 2 || die(  }
  1622.     return $self->_do_timeout('rea . "\n");
  1623.     my $self = shift;
  1624.     if ( ref($self->{fh}) eq 'IO::Socket::SSL' ) {
  1625.         return 1 if $self->{fh}->pending;
  1626.     }
  1627.     return $self->_do_timeout('read', )
  1628. )
  1629. }
  1630.  
  1631. sub can_write {
  1632.     my == 1 || as == 2 || die(iny->can_ssl();
  1633.     die $reason unless . "\n");
  1634.     my $self = shift;
  1635.     return $self->_do_timeout('write',  )
  1636. }
  1637.  
  1638. sub _assert_ssl {
  1639.     my($ok, $reason) = HTTP::Tiny->can_ssl();
  1640.     die $reason unless $ok;
  1641. }
  1642.  
  1643. sub can_reuse {
  1644.     my ($self,$scheme,$host,$port,$peer) = | ;
  1645.     return 0 if
  1646.         $self->{pid} != $
  1647.         || $self->{tid} != _get_tid()
  1648.         || length($self->{rbuf})
  1649.         || $scheme ne $self->{scheme}
  1650.         || $h# Try to find a CA bundle to validate the SSL cert,
  1651. # prefer Mozilla::CA or fallback to a system file
  1652. al { $self->can_read(0) }
  1653.         || if ;
  1654.         return 1;
  1655. }
  1656.  
  1657. # Try to find a CA bundle to validate the SSL cert,
  1658. # prefer Mozilla::CA or fallback to a system file
  1659. sub _find_CA_file {
  1660.     my $self = shift();
  1661.  
  1662.     my $ca_file =
  1663.       defined( $self->{SSL_options}->{SSL_ca_file} )
  1664.       ? $self->{SSL_options}->{SSL_ca_file}
  1665.       : $ENV{SSL_CERT_FILE};
  1666.  
  1667.     if ( defined $ca_file ) {
  1668.         unless ( -r $ca_file ) {
  1669.             die Mozilla::CA::SSL_ca_file()
  1670.         if eval { require M;
  1671.         }
  1672.         re# cert list copied from golang src/crypto/x509/root_unix.go
  1673.  $INC[-1] eq '.';
  1674.     return Mozilla::CA::SSL_ca_file()
  1675.         if eval { requ# Debian/Ubuntu/Gentoo etc.
  1676.  cert list copied from golang src/crypto/x509/root# Fedora/RHEL
  1677. oreach my $ca_bundle (
  1678.         ",                 # OpenSUSE
  1679.        "   # Debian/Ubuntu/Gentoo etc.
  1680.         "/# NetBSD
  1681. ls/certs/ca-bundle.crt",       # Fedora/RHEL
  1682.      # OpenBSD
  1683. sl/ca-bundle.pem",                 # OpenSUSE
  1684.     # FreeBSD/DragonFly
  1685. rts/ca-certificates.crt", # NetBSD
  1686.         "/etc/s# OpenELEC
  1687. ",                      # OpenBSD
  1688.         "/usr/lo# Solaris 11.2+
  1689. ca-root-nss.crt", # FreeBSD/DragonFly
  1690.         "/etc/pki/tls/cacert.pem",                # OpenELEC
  1691.         "/etc/certs/ca-certificates.crt",         # Solaris 11.2+
  1692.     ) {
  1693.         return $ca_bund# for thread safety, we need to know thread id if threads are loaded
  1694.  which to verify the SSL certificate.\n/
  1695.   # for 'threads'
  1696. talling Mozilla::CA from CPAN\n/;
  1697. }
  1698.  
  1699. # for thread safety, we need to know thread id if threads are loaded
  1700. sub _get_tid {
  1701.  # This test reimplements IO::Socket::SSL::can_client_sni(), which wasn't
  1702.  ? t# added until IO::Socket::SSL 1.84
  1703.  
  1704.     my ($self, $host) = NS;
  1705.  
  1706.     my %ssl_args;
  1707.  
  1708.     # This test reimplements IO::Socket::SSL::can_client_sni(), wh# Sane SNI support
  1709. ded until IO::Socket::SSL 1.84
  1710.     if ( Net::SSLeay::OPENSSL_VERSION_NUMBER() >= 0x01000# enable CN validation
  1711. gs{SSL_hostname} = $host,          # Sane SNI supp# set validation hostname
  1712. {verify_SSL}) {
  1713.         $ssl_args{SSL_verifycn_sch# enable cert validation
  1714. CN validation
  1715.         $ssl_args{SSL_verifycn_name}    = $host;  # set validation hostname
  1716.         $ssl_args{SSL_verify_mode}      =# disable CN validation
  1717. alidation
  1718.         $ssl_args{SSL_ca_file}          # disable cert validation
  1719.   }
  1720.     els# user options override settings from verify_SSL
  1721. ne'; # disable CN validation
  1722.         $ssl_args{SSL_verify_mode}      = 0x00;   # disable cert validation
  1723.     }
  1724.  
  1725.     # user options override settings from verify_SS=pod
  1726.  
  1727. =encoding UTF-8
  1728.  
  1729. =head1 NAME
  1730.  
  1731. HTTP::Tiny - A small, simple, correct HTTP/1.1 client
  1732.  
  1733. =head1 VERSION
  1734.  
  1735. version 0.070
  1736.  
  1737. =head1 SYNOPSIS
  1738.  
  1739.     use HTTP::Tiny;
  1740.  
  1741.     my $response = HTTP::Tiny->new->get('http://example.com/');
  1742.  
  1743.     die "Failed!\n" unless $response->{success};
  1744.  
  1745.     print "$response->{status} $response->{reason}\n";
  1746.  
  1747.     while (my ($k, $v) = each %{$response->{headers}}) {
  1748.         for (ref $v eq 'ARRAY' ? @$v : $v) {
  1749.             print "$k: $_\n";
  1750.         }
  1751.     }
  1752.  
  1753.     print $response->{content} if length $response->{content};
  1754.  
  1755. =head1 DESCRIPTION
  1756.  
  1757. This is a very simple HTTP/1.1 client, designed for doing simple
  1758. requests without the overhead of a large framework like L<LWP::UserAgent>.
  1759.  
  1760. It is more correct and more complete than L<HTTP::Lite>.  It supports
  1761. proxies and redirection.  It also correctly resumes after EINTR.
  1762.  
  1763. If L<IO::Socket::IP> 0.25 or later is installed, HTTP::Tiny will use it instead
  1764. of L<IO::Socket::INET> for transparent support for both IPv4 and IPv6.
  1765.  
  1766. Cookie support requires L<HTTP::CookieJar> or an equivalent class.
  1767.  
  1768. =head1 METHODS
  1769.  
  1770. =head2 new
  1771.  
  1772.     $http = HTTP::Tiny->new( %attributes );
  1773.  
  1774. This constructor returns a new HTTP::Tiny object.  Valid attributes include:
  1775.  
  1776. =over 4
  1777.  
  1778. =item *
  1779.  
  1780. C<agent> ā€” A user-agent string (defaults to 'HTTP-Tiny/$VERSION'). If C<agent> ā€” ends in a space character, the default user-agent string is appended.
  1781.  
  1782. =item *
  1783.  
  1784. C<cookie_jar> ā€” An instance of L<HTTP::CookieJar> ā€” or equivalent class that supports the C<add> and C<cookie_header> methods
  1785.  
  1786. =item *
  1787.  
  1788. C<default_headers> ā€” A hashref of default headers to apply to requests
  1789.  
  1790. =item *
  1791.  
  1792. C<local_address> ā€” The local IP address to bind to
  1793.  
  1794. =item *
  1795.  
  1796. C<keep_alive> ā€” Whether to reuse the last connection (if for the same scheme, host and port) (defaults to 1)
  1797.  
  1798. =item *
  1799.  
  1800. C<max_redirect> ā€” Maximum number of redirects allowed (defaults to 5)
  1801.  
  1802. =item *
  1803.  
  1804. C<max_size> ā€” Maximum response size in bytes (only when not using a data callback).  If defined, responses larger than this will return an exception.
  1805.  
  1806. =item *
  1807.  
  1808. C<http_proxy> ā€” URL of a proxy server to use for HTTP connections (default is C<$ENV{http_proxy}> ā€” if set)
  1809.  
  1810. =item *
  1811.  
  1812. C<https_proxy> ā€” URL of a proxy server to use for HTTPS connections (default is C<$ENV{https_proxy}> ā€” if set)
  1813.  
  1814. =item *
  1815.  
  1816. C<proxy> ā€” URL of a generic proxy server for both HTTP and HTTPS connections (default is C<$ENV{all_proxy}> ā€” if set)
  1817.  
  1818. =item *
  1819.  
  1820. C<no_proxy> ā€” List of domain suffixes that should not be proxied.  Must be a comma-separated string or an array reference. (default is C<$ENV{no_proxy}> ā€”)
  1821.  
  1822. =item *
  1823.  
  1824. C<timeout> ā€” Request timeout in seconds (default is 60) If a socket open, read or write takes longer than the timeout, an exception is thrown.
  1825.  
  1826. =item *
  1827.  
  1828. C<verify_SSL> ā€” A boolean that indicates whether to validate the SSL certificate of an C<https> ā€” connection (default is false)
  1829.  
  1830. =item *
  1831.  
  1832. C<SSL_options> ā€” A hashref of C<SSL_*> ā€” options to pass through to L<IO::Socket::SSL>
  1833.  
  1834. =back
  1835.  
  1836. Passing an explicit C<undef> for C<proxy>, C<http_proxy> or C<https_proxy> will
  1837. prevent getting the corresponding proxies from the environment.
  1838.  
  1839. Exceptions from C<max_size>, C<timeout> or other errors will result in a
  1840. pseudo-HTTP status code of 599 and a reason of "Internal Exception". The
  1841. content field in the response will contain the text of the exception.
  1842.  
  1843. The C<keep_alive> parameter enables a persistent connection, but only to a
  1844. single destination scheme, host and port.  Also, if any connection-relevant
  1845. attributes are modified, or if the process ID or thread ID change, the
  1846. persistent connection will be dropped.  If you want persistent connections
  1847. across multiple destinations, use multiple HTTP::Tiny objects.
  1848.  
  1849. See L</SSL SUPPORT> for more on the C<verify_SSL> and C<SSL_options> attributes.
  1850.  
  1851. =head2 get|head|put|post|delete
  1852.  
  1853.     $response = $http->get($url);
  1854.     $response = $http->get($url, \%options);
  1855.     $response = $http->head($url);
  1856.  
  1857. These methods are shorthand for calling C<request()> for the given method.  The
  1858. URL must have unsafe characters escaped and international domain names encoded.
  1859. See C<request()> for valid options and a description of the response.
  1860.  
  1861. The C<success> field of the response will be true if the status code is 2XX.
  1862.  
  1863. =head2 post_form
  1864.  
  1865.     $response = $http->post_form($url, $form_data);
  1866.     $response = $http->post_form($url, $form_data, \%options);
  1867.  
  1868. This method executes a C<POST> request and sends the key/value pairs from a
  1869. form data hash or array reference to the given URL with a C<content-type> of
  1870. C<application/x-www-form-urlencoded>.  If data is provided as an array
  1871. reference, the order is preserved; if provided as a hash reference, the terms
  1872. are sorted on key and value for consistency.  See documentation for the
  1873. C<www_form_urlencode> method for details on the encoding.
  1874.  
  1875. The URL must have unsafe characters escaped and international domain names
  1876. encoded.  See C<request()> for valid options and a description of the response.
  1877. Any C<content-type> header or content in the options hashref will be ignored.
  1878.  
  1879. The C<success> field of the response will be true if the status code is 2XX.
  1880.  
  1881. =head2 mirror
  1882.  
  1883.     $response = $http->mirror($url, $file, \%options)
  1884.     if ( $response->{success} ) {
  1885.         print "$file is up to date\n";
  1886.     }
  1887.  
  1888. Executes a C<GET> request for the URL and saves the response body to the file
  1889. name provided.  The URL must have unsafe characters escaped and international
  1890. domain names encoded.  If the file already exists, the request will include an
  1891. C<If-Modified-Since> header with the modification timestamp of the file.  You
  1892. may specify a different C<If-Modified-Since> header yourself in the C<<
  1893. $options->{headers} >> hash.
  1894.  
  1895. The C<success> field of the response will be true if the status code is 2XX
  1896. or if the status code is 304 (unmodified).
  1897.  
  1898. If the file was modified and the server response includes a properly
  1899. formatted C<Last-Modified> header, the file modification time will
  1900. be updated accordingly.
  1901.  
  1902. =head2 request
  1903.  
  1904.     $response = $http->request($method, $url);
  1905.     $response = $http->request($method, $url, \%options);
  1906.  
  1907. Executes an HTTP request of the given method type ('GET', 'HEAD', 'POST',
  1908. 'PUT', etc.) on the given URL.  The URL must have unsafe characters escaped and
  1909. international domain names encoded.
  1910.  
  1911. If the URL includes a "user:password" stanza, they will be used for Basic-style
  1912. authorization headers.  (Authorization headers will not be included in a
  1913. redirected request.) For example:
  1914.  
  1915.     $http->request('GET', 'http://Aladdin:open sesame@example.com/');
  1916.  
  1917. If the "user:password" stanza contains reserved characters, they must
  1918. be percent-escaped:
  1919.  
  1920.     $http->request('GET', 'http://john%40example.com:password@example.com/');
  1921.  
  1922. A hashref of options may be appended to modify the request.
  1923.  
  1924. Valid options are:
  1925.  
  1926. =over 4
  1927.  
  1928. =item *
  1929.  
  1930. C<headers> ā€” A hashref containing headers to include with the request.  If the value for a header is an array reference, the header will be output multiple times with each value in the array.  These headers over-write any default headers.
  1931.  
  1932. =item *
  1933.  
  1934. C<content> ā€” A scalar to include as the body of the request OR a code reference that will be called iteratively to produce the body of the request
  1935.  
  1936. =item *
  1937.  
  1938. C<trailer_callback> ā€” A code reference that will be called if it exists to provide a hashref of trailing headers (only used with chunked transfer-encoding)
  1939.  
  1940. =item *
  1941.  
  1942. C<data_callback> ā€” A code reference that will be called for each chunks of the response body received.
  1943.  
  1944. =item *
  1945.  
  1946. C<peer> ā€” Override host resolution and force all connections to go only to a specific peer address, regardless of the URL of the request.  This will include any redirections!  This options should be used with extreme caution (e.g. debugging or very special circumstances).
  1947.  
  1948. =back
  1949.  
  1950. The C<Host> header is generated from the URL in accordance with RFC 2616.  It
  1951. is a fatal error to specify C<Host> in the C<headers> option.  Other headers
  1952. may be ignored or overwritten if necessary for transport compliance.
  1953.  
  1954. If the C<content> option is a code reference, it will be called iteratively
  1955. to provide the content body of the request.  It should return the empty
  1956. string or undef when the iterator is exhausted.
  1957.  
  1958. If the C<content> option is the empty string, no C<content-type> or
  1959. C<content-length> headers will be generated.
  1960.  
  1961. If the C<data_callback> option is provided, it will be called iteratively until
  1962. the entire response body is received.  The first argument will be a string
  1963. containing a chunk of the response body, the second argument will be the
  1964. in-progress response hash reference, as described below.  (This allows
  1965. customizing the action of the callback based on the C<status> or C<headers>
  1966. received prior to the content body.)
  1967.  
  1968. The C<request> method returns a hashref containing the response.  The hashref
  1969. will have the following keys:
  1970.  
  1971. =over 4
  1972.  
  1973. =item *
  1974.  
  1975. C<success> ā€” Boolean indicating whether the operation returned a 2XX status code
  1976.  
  1977. =item *
  1978.  
  1979. C<url> ā€” URL that provided the response. This is the URL of the request unless there were redirections, in which case it is the last URL queried in a redirection chain
  1980.  
  1981. =item *
  1982.  
  1983. C<status> ā€” The HTTP status code of the response
  1984.  
  1985. =item *
  1986.  
  1987. C<reason> ā€” The response phrase returned by the server
  1988.  
  1989. =item *
  1990.  
  1991. C<content> ā€” The body of the response.  If the response does not have any content or if a data callback is provided to consume the response body, this will be the empty string
  1992.  
  1993. =item *
  1994.  
  1995. C<headers> ā€” A hashref of header fields.  All header field names will be normalized to be lower case. If a header is repeated, the value will be an arrayref; it will otherwise be a scalar string containing the value
  1996.  
  1997. =item *
  1998.  
  1999. C<redirects> If this field exists, it is an arrayref of response hash references from redirects in the same order that redirections occurred.  If it does not exist, then no redirections occurred.
  2000.  
  2001. =back
  2002.  
  2003. On an exception during the execution of the request, the C<status> field will
  2004. contain 599, and the C<content> field will contain the text of the exception.
  2005.  
  2006. =head2 www_form_urlencode
  2007.  
  2008.     $params = $http->www_form_urlencode( $data );
  2009.     $response = $http->get("http://example.com/query?$params");
  2010.  
  2011. This method converts the key/value pairs from a data hash or array reference
  2012. into a C<x-www-form-urlencoded> string.  The keys and values from the data
  2013. reference will be UTF-8 encoded and escaped per RFC 3986.  If a value is an
  2014. array reference, the key will be repeated with each of the values of the array
  2015. reference.  If data is provided as a hash reference, the key/value pairs in the
  2016. resulting string will be sorted by key and value for consistent ordering.
  2017.  
  2018. =head2 can_ssl
  2019.  
  2020.     $ok         = HTTP::Tiny->can_ssl;
  2021.     ($ok, $why) = HTTP::Tiny->can_ssl;
  2022.     ($ok, $why) = $http->can_ssl;
  2023.  
  2024. Indicates if SSL support is available.  When called as a class object, it
  2025. checks for the correct version of L<Net::SSLeay> and L<IO::Socket::SSL>.
  2026. When called as an object methods, if C<SSL_verify> is true or if C<SSL_verify_mode>
  2027. is set in C<SSL_options>, it checks that a CA file is available.
  2028.  
  2029. In scalar context, returns a boolean indicating if SSL is available.
  2030. In list context, returns the boolean and a (possibly multi-line) string of
  2031. errors indicating why SSL isn't available.
  2032.  
  2033. =head2 connected
  2034.  
  2035.     $host = $http->connected;
  2036.     ($host, $port) = $http->connected;
  2037.  
  2038. Indicates if a connection to a peer is being kept alive, per the C<keep_alive>
  2039. option.
  2040.  
  2041. In scalar context, returns the peer host and port, joined with a colon, or
  2042. C<undef> (if no peer is connected).
  2043. In list context, returns the peer host and port or an empty list (if no peer
  2044. is connected).
  2045.  
  2046. B<Note>: This method cannot reliably be used to discover whether the remote
  2047. host has closed its end of the socket.
  2048.  
  2049. =for Pod::Coverage SSL_options
  2050. agent
  2051. cookie_jar
  2052. default_headers
  2053. http_proxy
  2054. https_proxy
  2055. keep_alive
  2056. local_address
  2057. max_redirect
  2058. max_size
  2059. no_proxy
  2060. proxy
  2061. timeout
  2062. verify_SSL
  2063.  
  2064. =head1 SSL SUPPORT
  2065.  
  2066. Direct C<https> connections are supported only if L<IO::Socket::SSL> 1.56 or
  2067. greater and L<Net::SSLeay> 1.49 or greater are installed. An exception will be
  2068. thrown if new enough versions of these modules are not installed or if the SSL
  2069. encryption fails. You can also use C<HTTP::Tiny::can_ssl()> utility function
  2070. that returns boolean to see if the required modules are installed.
  2071.  
  2072. An C<https> connection may be made via an C<http> proxy that supports the CONNECT
  2073. command (i.e. RFC 2817).  You may not proxy C<https> via a proxy that itself
  2074. requires C<https> to communicate.
  2075.  
  2076. SSL provides two distinct capabilities:
  2077.  
  2078. =over 4
  2079.  
  2080. =item *
  2081.  
  2082. Encrypted communication channel
  2083.  
  2084. =item *
  2085.  
  2086. Verification of server identity
  2087.  
  2088. =back
  2089.  
  2090. B<By default, HTTP::Tiny does not verify server identity>.
  2091.  
  2092. Server identity verification is controversial and potentially tricky because it
  2093. depends on a (usually paid) third-party Certificate Authority (CA) trust model
  2094. to validate a certificate as legitimate.  This discriminates against servers
  2095. with self-signed certificates or certificates signed by free, community-driven
  2096. CA's such as L<CAcert.org|http://cacert.org>.
  2097.  
  2098. By default, HTTP::Tiny does not make any assumptions about your trust model,
  2099. threat level or risk tolerance.  It just aims to give you an encrypted channel
  2100. when you need one.
  2101.  
  2102. Setting the C<verify_SSL> attribute to a true value will make HTTP::Tiny verify
  2103. that an SSL connection has a valid SSL certificate corresponding to the host
  2104. name of the connection and that the SSL certificate has been verified by a CA.
  2105. Assuming you trust the CA, this will protect against a L<man-in-the-middle
  2106. attack|http://en.wikipedia.org/wiki/Man-in-the-middle_attack>.  If you are
  2107. concerned about security, you should enable this option.
  2108.  
  2109. Certificate verification requires a file containing trusted CA certificates.
  2110.  
  2111. If the environment variable C<SSL_CERT_FILE> is present, HTTP::Tiny
  2112. will try to find a CA certificate file in that location.
  2113.  
  2114. If the L<Mozilla::CA> module is installed, HTTP::Tiny will use the CA file
  2115. included with it as a source of trusted CA's.  (This means you trust Mozilla,
  2116. the author of Mozilla::CA, the CPAN mirror where you got Mozilla::CA, the
  2117. toolchain used to install it, and your operating system security, right?)
  2118.  
  2119. If that module is not available, then HTTP::Tiny will search several
  2120. system-specific default locations for a CA certificate file:
  2121.  
  2122. =over 4
  2123.  
  2124. =item *
  2125.  
  2126. /etc/ssl/certs/ca-certificates.crt
  2127.  
  2128. =item *
  2129.  
  2130. /etc/pki/tls/certs/ca-bundle.crt
  2131.  
  2132. =item *
  2133.  
  2134. /etc/ssl/ca-bundle.pem
  2135.  
  2136. =back
  2137.  
  2138. An exception will be raised if C<verify_SSL> is true and no CA certificate file
  2139. is available.
  2140.  
  2141. If you desire complete control over SSL connections, the C<SSL_options> attribute
  2142. lets you provide a hash reference that will be passed through to
  2143. C<IO::Socket::SSL::start_SSL()>, overriding any options set by HTTP::Tiny. For
  2144. example, to provide your own trusted CA file:
  2145.  
  2146.     SSL_options => {
  2147.         SSL_ca_file => $file_path,
  2148.     }
  2149.  
  2150. The C<SSL_options> attribute could also be used for such things as providing a
  2151. client certificate for authentication to a server or controlling the choice of
  2152. cipher used for the SSL connection. See L<IO::Socket::SSL> documentation for
  2153. details.
  2154.  
  2155. =head1 PROXY SUPPORT
  2156.  
  2157. HTTP::Tiny can proxy both C<http> and C<https> requests.  Only Basic proxy
  2158. authorization is supported and it must be provided as part of the proxy URL:
  2159. C<http://user:pass@proxy.example.com/>.
  2160.  
  2161. HTTP::Tiny supports the following proxy environment variables:
  2162.  
  2163. =over 4
  2164.  
  2165. =item *
  2166.  
  2167. http_proxy or HTTP_PROXY
  2168.  
  2169. =item *
  2170.  
  2171. https_proxy or HTTPS_PROXY
  2172.  
  2173. =item *
  2174.  
  2175. all_proxy or ALL_PROXY
  2176.  
  2177. =back
  2178.  
  2179. If the C<REQUEST_METHOD> environment variable is set, then this might be a CGI
  2180. process and C<HTTP_PROXY> would be set from the C<Proxy:> header, which is a
  2181. security risk.  If C<REQUEST_METHOD> is set, C<HTTP_PROXY> (the upper case
  2182. variant only) is ignored.
  2183.  
  2184. Tunnelling C<https> over an C<http> proxy using the CONNECT method is
  2185. supported.  If your proxy uses C<https> itself, you can not tunnel C<https>
  2186. over it.
  2187.  
  2188. Be warned that proxying an C<https> connection opens you to the risk of a
  2189. man-in-the-middle attack by the proxy server.
  2190.  
  2191. The C<no_proxy> environment variable is supported in the format of a
  2192. comma-separated list of domain extensions proxy should not be used for.
  2193.  
  2194. Proxy arguments passed to C<new> will override their corresponding
  2195. environment variables.
  2196.  
  2197. =head1 LIMITATIONS
  2198.  
  2199. HTTP::Tiny is I<conditionally compliant> with the
  2200. L<HTTP/1.1 specifications|http://www.w3.org/Protocols/>:
  2201.  
  2202. =over 4
  2203.  
  2204. =item *
  2205.  
  2206. "Message Syntax and Routing" [RFC7230]
  2207.  
  2208. =item *
  2209.  
  2210. "Semantics and Content" [RFC7231]
  2211.  
  2212. =item *
  2213.  
  2214. "Conditional Requests" [RFC7232]
  2215.  
  2216. =item *
  2217.  
  2218. "Range Requests" [RFC7233]
  2219.  
  2220. =item *
  2221.  
  2222. "Caching" [RFC7234]
  2223.  
  2224. =item *
  2225.  
  2226. "Authentication" [RFC7235]
  2227.  
  2228. =back
  2229.  
  2230. It attempts to meet all "MUST" requirements of the specification, but does not
  2231. implement all "SHOULD" requirements.  (Note: it was developed against the
  2232. earlier RFC 2616 specification and may not yet meet the revised RFC 7230-7235
  2233. spec.)
  2234.  
  2235. Some particular limitations of note include:
  2236.  
  2237. =over
  2238.  
  2239. =item *
  2240.  
  2241. HTTP::Tiny focuses on correct transport.  Users are responsible for ensuring
  2242. that user-defined headers and content are compliant with the HTTP/1.1
  2243. specification.
  2244.  
  2245. =item *
  2246.  
  2247. Users must ensure that URLs are properly escaped for unsafe characters and that
  2248. international domain names are properly encoded to ASCII. See L<URI::Escape>,
  2249. L<URI::_punycode> and L<Net::IDN::Encode>.
  2250.  
  2251. =item *
  2252.  
  2253. Redirection is very strict against the specification.  Redirection is only
  2254. automatic for response codes 301, 302, 307 and 308 if the request method is
  2255. 'GET' or 'HEAD'.  Response code 303 is always converted into a 'GET'
  2256. redirection, as mandated by the specification.  There is no automatic support
  2257. for status 305 ("Use proxy") redirections.
  2258.  
  2259. =item *
  2260.  
  2261. There is no provision for delaying a request body using an C<Expect> header.
  2262. Unexpected C<1XX> responses are silently ignored as per the specification.
  2263.  
  2264. =item *
  2265.  
  2266. Only 'chunked' C<Transfer-Encoding> is supported.
  2267.  
  2268. =item *
  2269.  
  2270. There is no support for a Request-URI of '*' for the 'OPTIONS' request.
  2271.  
  2272. =item *
  2273.  
  2274. Headers mentioned in the RFCs and some other, well-known headers are
  2275. generated with their canonical case.  Other headers are sent in the
  2276. case provided by the user.  Except for control headers (which are sent first),
  2277. headers are sent in arbitrary order.
  2278.  
  2279. =back
  2280.  
  2281. Despite the limitations listed above, HTTP::Tiny is considered
  2282. feature-complete.  New feature requests should be directed to
  2283. L<HTTP::Tiny::UA>.
  2284.  
  2285. =head1 SEE ALSO
  2286.  
  2287. =over 4
  2288.  
  2289. =item *
  2290.  
  2291. L<HTTP::Tiny::UA> - Higher level UA features for HTTP::Tiny
  2292.  
  2293. =item *
  2294.  
  2295. L<HTTP::Thin> - HTTP::Tiny wrapper with L<HTTP::Request>/L<HTTP::Response> compatibility
  2296.  
  2297. =item *
  2298.  
  2299. L<HTTP::Tiny::Mech> - Wrap L<WWW::Mechanize> instance in HTTP::Tiny compatible interface
  2300.  
  2301. =item *
  2302.  
  2303. L<IO::Socket::IP> - Required for IPv6 support
  2304.  
  2305. =item *
  2306.  
  2307. L<IO::Socket::SSL> - Required for SSL support
  2308.  
  2309. =item *
  2310.  
  2311. L<LWP::UserAgent> - If HTTP::Tiny isn't enough for you, this is the "standard" way to do things
  2312.  
  2313. =item *
  2314.  
  2315. L<Mozilla::CA> - Required if you want to validate SSL certificates
  2316.  
  2317. =item *
  2318.  
  2319. L<Net::SSLeay> - Required for SSL support
  2320.  
  2321. =back
  2322.  
  2323. =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
  2324.  
  2325. =head1 SUPPORT
  2326.  
  2327. =head2 Bugs / Feature Requests
  2328.  
  2329. Please report any bugs or feature requests through the issue tracker
  2330. at L<https://github.com/chansen/p5-http-tiny/issues>.
  2331. You will be notified automatically of any progress on your issue.
  2332.  
  2333. =head2 Source Code
  2334.  
  2335. This is open source software.  The code repository is available for
  2336. public review and contribution under the terms of the license.
  2337.  
  2338. L<https://github.com/chansen/p5-http-tiny>
  2339.  
  2340.   git clone https://github.com/chansen/p5-http-tiny.git
  2341.  
  2342. =head1 AUTHORS
  2343.  
  2344. =over 4
  2345.  
  2346. =item *
  2347.  
  2348. Christian Hansen <chansen@cpan.org>
  2349.  
  2350. =item *
  2351.  
  2352. David Golden <dagolden@cpan.org>
  2353.  
  2354. =back
  2355.  
  2356. =head1 CONTRIBUTORS
  2357.  
  2358. =for stopwords Alan Gardner Alessandro Ghedini A. Sinan Unur Brad Gilbert brian m. carlson Chris Nehren Weyl Claes Jakobsson Clinton Gormley Craig Berry David Golden Dean Pearce Edward Zborowski James Raspass Jeremy Mates Jess Robinson Karen Etheridge Lukas Eklund Martin J. Evans Martin-Louis Bright Mike Doherty Nicolas Rochelemagne Olaf Alders Olivier MenguĆ© Petr PĆ­saÅ™ SkyMarshal Sƶren Kornetzki Steve Grazzini Syohei YOSHIDA Tatsuhiko Miyagawa Tom Hukins Tony Cook
  2359.  
  2360. =over 4
  2361.  
  2362. =item *
  2363.  
  2364. Alan Gardner <gardner@pythian.com>
  2365.  
  2366. =item *
  2367.  
  2368. Alessandro Ghedini <al3xbio@gmail.com>
  2369.  
  2370. =item *
  2371.  
  2372. A. Sinan Unur <nanis@cpan.org>
  2373.  
  2374. =item *
  2375.  
  2376. Brad Gilbert <bgills@cpan.org>
  2377.  
  2378. =item *
  2379.  
  2380. brian m. carlson <sandals@crustytoothpaste.net>
  2381.  
  2382. =item *
  2383.  
  2384. Chris Nehren <apeiron@cpan.org>
  2385.  
  2386. =item *
  2387.  
  2388. Chris Weyl <cweyl@alumni.drew.edu>
  2389.  
  2390. =item *
  2391.  
  2392. Claes Jakobsson <claes@surfar.nu>
  2393.  
  2394. =item *
  2395.  
  2396. Clinton Gormley <clint@traveljury.com>
  2397.  
  2398. =item *
  2399.  
  2400. Craig A. Berry <craigberry@mac.com>
  2401.  
  2402. =item *
  2403.  
  2404. David Golden <xdg@xdg.me>
  2405.  
  2406. =item *
  2407.  
  2408. Dean Pearce <pearce@pythian.com>
  2409.  
  2410. =item *
  2411.  
  2412. Edward Zborowski <ed@rubensteintech.com>
  2413.  
  2414. =item *
  2415.  
  2416. James Raspass <jraspass@gmail.com>
  2417.  
  2418. =item *
  2419.  
  2420. Jeremy Mates <jmates@cpan.org>
  2421.  
  2422. =item *
  2423.  
  2424. Jess Robinson <castaway@desert-island.me.uk>
  2425.  
  2426. =item *
  2427.  
  2428. Karen Etheridge <ether@cpan.org>
  2429.  
  2430. =item *
  2431.  
  2432. Lukas Eklund <leklund@gmail.com>
  2433.  
  2434. =item *
  2435.  
  2436. Martin J. Evans <mjegh@ntlworld.com>
  2437.  
  2438. =item *
  2439.  
  2440. Martin-Louis Bright <mlbright@gmail.com>
  2441.  
  2442. =item *
  2443.  
  2444. Mike Doherty <doherty@cpan.org>
  2445.  
  2446. =item *
  2447.  
  2448. Nicolas Rochelemagne <rochelemagne@cpanel.net>
  2449.  
  2450. =item *
  2451.  
  2452. Olaf Alders <olaf@wundersolutions.com>
  2453.  
  2454. =item *
  2455.  
  2456. Olivier MenguƩ <dolmen@cpan.org>
  2457.  
  2458. =item *
  2459.  
  2460. Petr PĆ­saÅ™ <ppisar@redhat.com>
  2461.  
  2462. =item *
  2463.  
  2464. SkyMarshal <skymarshal1729@gmail.com>
  2465.  
  2466. =item *
  2467.  
  2468. Sƶren Kornetzki <soeren.kornetzki@delti.com>
  2469.  
  2470. =item *
  2471.  
  2472. Steve Grazzini <steve.grazzini@grantstreet.com>
  2473.  
  2474. =item *
  2475.  
  2476. Syohei YOSHIDA <syohex@gmail.com>
  2477.  
  2478. =item *
  2479.  
  2480. Tatsuhiko Miyagawa <miyagawa@bulknews.net>
  2481.  
  2482. =item *
  2483.  
  2484. Tom Hukins <tom@eborcom.com>
  2485.  
  2486. =item *
  2487.  
  2488. Tony Cook <tony@develop-help.com>
  2489.  
  2490. =back
  2491.  
  2492. =head1 COPYRIGHT AND LICENSE
  2493.  
  2494. This software is copyright (c) by Christian Hansen.
  2495.  
  2496. This is free software; you can redistribute it and/or modify it under
  2497. the same terms as the Perl 5 programming language system itself.
  2498.  
  2499. =cut

Raw Paste


Login or Register to edit or fork this paste. It's free.