PERL   437

Tiny.pm

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

Raw Paste


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