From 99527ef152b4e2e3b029babe6e41c46c37429bf7 Mon Sep 17 00:00:00 2001 From: Steve Hay Date: Fri, 5 Jun 2015 08:42:14 +0100 Subject: [PATCH] Upgrade HTTP-Tiny from version 0.054 to 0.056 --- Porting/Maintainers.pl | 3 +- cpan/HTTP-Tiny/lib/HTTP/Tiny.pm | 131 ++++++++++++++++++++++++++++++---------- cpan/HTTP-Tiny/t/001_api.t | 2 +- pod/perldelta.pod | 4 ++ 4 files changed, 106 insertions(+), 34 deletions(-) diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index e65df8e..755b41e 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -611,7 +611,7 @@ use File::Glob qw(:case); }, 'HTTP::Tiny' => { - 'DISTRIBUTION' => 'DAGOLDEN/HTTP-Tiny-0.054.tar.gz', + 'DISTRIBUTION' => 'DAGOLDEN/HTTP-Tiny-0.056.tar.gz', 'FILES' => q[cpan/HTTP-Tiny], 'EXCLUDED' => [ 't/00-report-prereqs.t', @@ -619,6 +619,7 @@ use File::Glob qw(:case); 't/200_live.t', 't/200_live_local_ip.t', 't/210_live_ssl.t', + qr/^corpus/, qr/^eg/, qr/^xt/ ], diff --git a/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm b/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm index 878cce8..52887d1 100644 --- a/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm +++ b/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm @@ -4,7 +4,7 @@ use strict; use warnings; # ABSTRACT: A small, simple, correct HTTP/1.1 client -our $VERSION = '0.054'; +our $VERSION = '0.056'; use Carp (); @@ -28,7 +28,7 @@ use Carp (); #pod * C — #pod Maximum number of redirects allowed (defaults to 5) #pod * C — -#pod Maximum response size (only when not using a data callback). If defined, responses larger than this will return an exception. +#pod Maximum response size in bytes (only when not using a data callback). If defined, responses larger than this will return an exception. #pod * C — #pod URL of a proxy server to use for HTTP connections (default is C<$ENV{http_proxy}> — if set) #pod * C — @@ -462,6 +462,55 @@ sub www_form_urlencode { return join("&", (ref $data eq 'ARRAY') ? (@terms) : (sort @terms) ); } +#pod =method can_ssl +#pod +#pod $ok = HTTP::Tiny->can_ssl; +#pod ($ok, $why) = HTTP::Tiny->can_ssl; +#pod ($ok, $why) = $http->can_ssl; +#pod +#pod Indicates if SSL support is available. When called as a class object, it +#pod checks for the correct version of L and L. +#pod When called as an object methods, if C is true or if C +#pod is set in C, it checks that a CA file is available. +#pod +#pod In scalar context, returns a boolean indicating if SSL is available. +#pod In list context, returns the boolean and a (possibly multi-line) string of +#pod errors indicating why SSL isn't available. +#pod +#pod =cut + +sub can_ssl { + my ($self) = @_; + + my($ok, $reason) = (1, ''); + + # Need IO::Socket::SSL 1.42 for SSL_create_ctx_callback + unless (eval {require IO::Socket::SSL; IO::Socket::SSL->VERSION(1.42)}) { + $ok = 0; + $reason .= qq/IO::Socket::SSL 1.42 must be installed for https support\n/; + } + + # Need Net::SSLeay 1.49 for MODE_AUTO_RETRY + unless (eval {require Net::SSLeay; Net::SSLeay->VERSION(1.49)}) { + $ok = 0; + $reason .= qq/Net::SSLeay 1.49 must be installed for https support\n/; + } + + # If an object, check that SSL config lets us get a CA if necessary + if ( ref($self) && ( $self->{verify_SSL} || $self->{SSL_options}{SSL_verify_mode} ) ) { + my $handle = HTTP::Tiny::Handle->new( + SSL_options => $self->{SSL_options}, + verify_SSL => $self->{verify_SSL}, + ); + unless ( eval { $handle->_find_CA_file; 1 } ) { + $ok = 0; + $reason .= "$@"; + } + } + + wantarray ? ($ok, $reason) : $ok; +} + #--------------------------------------------------------------------------# # private methods #--------------------------------------------------------------------------# @@ -766,7 +815,7 @@ sub _maybe_redirect { my ($self, $request, $response, $args) = @_; my $headers = $response->{headers}; my ($status, $method) = ($response->{status}, $request->{method}); - if (($status eq '303' or ($status =~ /^30[127]/ && $method =~ /^GET|HEAD$/)) + if (($status eq '303' or ($status =~ /^30[1278]/ && $method =~ /^GET|HEAD$/)) and $headers->{location} and ++$args->{redirects} <= $self->{max_redirect} ) { @@ -1362,12 +1411,8 @@ sub can_write { } sub _assert_ssl { - # Need IO::Socket::SSL 1.42 for SSL_create_ctx_callback - die(qq/IO::Socket::SSL 1.42 must be installed for https support\n/) - unless eval {require IO::Socket::SSL; IO::Socket::SSL->VERSION(1.42)}; - # Need Net::SSLeay 1.49 for MODE_AUTO_RETRY - die(qq/Net::SSLeay 1.49 must be installed for https support\n/) - unless eval {require Net::SSLeay; Net::SSLeay->VERSION(1.49)}; + my($ok, $reason) = HTTP::Tiny->can_ssl(); + die $reason unless $ok; } sub can_reuse { @@ -1389,11 +1434,15 @@ sub can_reuse { sub _find_CA_file { my $self = shift(); - return $self->{SSL_options}->{SSL_ca_file} - if $self->{SSL_options}->{SSL_ca_file} and -e $self->{SSL_options}->{SSL_ca_file}; + if ( $self->{SSL_options}->{SSL_ca_file} ) { + unless ( -r $self->{SSL_options}->{SSL_ca_file} ) { + die qq/SSL_ca_file '$self->{SSL_options}->{SSL_ca_file}' not found or not readable\n/; + } + return $self->{SSL_options}->{SSL_ca_file}; + } return Mozilla::CA::SSL_ca_file() - if eval { require Mozilla::CA }; + if eval { require Mozilla::CA; 1 }; # cert list copied from golang src/crypto/x509/root_unix.go foreach my $ca_bundle ( @@ -1463,7 +1512,7 @@ HTTP::Tiny - A small, simple, correct HTTP/1.1 client =head1 VERSION -version 0.054 +version 0.056 =head1 SYNOPSIS @@ -1532,7 +1581,7 @@ C — Maximum number of redirects allowed (defaults to 5) =item * -C — Maximum response size (only when not using a data callback). If defined, responses larger than this will return an exception. +C — Maximum response size in bytes (only when not using a data callback). If defined, responses larger than this will return an exception. =item * @@ -1738,6 +1787,21 @@ array reference, the key will be repeated with each of the values of the array reference. If data is provided as a hash reference, the key/value pairs in the resulting string will be sorted by key and value for consistent ordering. +=head2 can_ssl + + $ok = HTTP::Tiny->can_ssl; + ($ok, $why) = HTTP::Tiny->can_ssl; + ($ok, $why) = $http->can_ssl; + +Indicates if SSL support is available. When called as a class object, it +checks for the correct version of L and L. +When called as an object methods, if C is true or if C +is set in C, it checks that a CA file is available. + +In scalar context, returns a boolean indicating if SSL is available. +In list context, returns the boolean and a (possibly multi-line) string of +errors indicating why SSL isn't available. + =for Pod::Coverage SSL_options agent cookie_jar @@ -1758,9 +1822,12 @@ verify_SSL Direct C connections are supported only if L 1.56 or greater and L 1.49 or greater are installed. An exception will be thrown if new enough versions of these modules are not installed or if the SSL -encryption fails. An C connection may be made via an C proxy that -supports the CONNECT command (i.e. RFC 2817). You may not proxy C via -a proxy that itself requires C to communicate. +encryption fails. You can also use C utility function +that returns boolean to see if the required modules are installed. + +An C connection may be made via an C proxy that supports the CONNECT +command (i.e. RFC 2817). You may not proxy C via a proxy that itself +requires C to communicate. SSL provides two distinct capabilities: @@ -1936,10 +2003,10 @@ L and L. =item * Redirection is very strict against the specification. Redirection is only -automatic for response codes 301, 302 and 307 if the request method is 'GET' or -'HEAD'. Response code 303 is always converted into a 'GET' redirection, as -mandated by the specification. There is no automatic support for status 305 -("Use proxy") redirections. +automatic for response codes 301, 302, 307 and 308 if the request method is +'GET' or 'HEAD'. Response code 303 is always converted into a 'GET' +redirection, as mandated by the specification. There is no automatic support +for status 305 ("Use proxy") redirections. =item * @@ -2033,7 +2100,7 @@ David Golden =head1 CONTRIBUTORS -=for stopwords Alan Gardner Alessandro Ghedini Brad Gilbert Chris Nehren Weyl Claes Jakobsson Clinton Gormley Craig Berry David Mitchell Dean Pearce Edward Zborowski James Raspass Jess Robinson Lukas Eklund Martin J. Evans Martin-Louis Bright Mike Doherty Olaf Alders Petr Písař Serguei Trouchelle Sören Kornetzki Syohei YOSHIDA Tom Hukins Tony Cook +=for stopwords Alan Gardner Alessandro Ghedini Brad Gilbert Chris Nehren Weyl Claes Jakobsson Clinton Gormley Dean Pearce Edward Zborowski James Raspass Jeremy Mates Jess Robinson Lukas Eklund Martin J. Evans Martin-Louis Bright Mike Doherty Olaf Alders Olivier Mengué Petr Písař Sören Kornetzki Syohei YOSHIDA Tatsuhiko Miyagawa Tom Hukins Tony Cook =over 4 @@ -2067,14 +2134,6 @@ Clinton Gormley =item * -Craig Berry - -=item * - -David Mitchell - -=item * - Dean Pearce =item * @@ -2087,6 +2146,10 @@ James Raspass =item * +Jeremy Mates + +=item * + Jess Robinson =item * @@ -2111,11 +2174,11 @@ Olaf Alders =item * -Petr Písař +Olivier Mengué =item * -Serguei Trouchelle +Petr Písař =item * @@ -2127,6 +2190,10 @@ Syohei YOSHIDA =item * +Tatsuhiko Miyagawa + +=item * + Tom Hukins =item * diff --git a/cpan/HTTP-Tiny/t/001_api.t b/cpan/HTTP-Tiny/t/001_api.t index 8e6ccd2..879a225 100644 --- a/cpan/HTTP-Tiny/t/001_api.t +++ b/cpan/HTTP-Tiny/t/001_api.t @@ -11,7 +11,7 @@ my @accessors = qw( max_redirect max_size proxy no_proxy timeout SSL_options verify_SSL cookie_jar ); my @methods = qw( - new get head put post delete post_form request mirror www_form_urlencode + new get head put post delete post_form request mirror www_form_urlencode can_ssl ); my %api; diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 039b6c4..f1ba720 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -128,6 +128,10 @@ L has been upgraded from version 2.45 to 2.46. =item * +L has been upgraded from version 0.054 to 0.056. + +=item * + L has been upgraded from version 1.9997 to 1.999701. Correct the behaviour of bdiv() and bmod() in list context. [perl #124300] -- 1.8.3.1