diff options
author | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2011-01-17 12:35:54 +0000 |
---|---|---|
committer | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2011-01-17 12:35:54 +0000 |
commit | eee47ba661717bca7751443be1b6ac8f8f64585a (patch) | |
tree | 633406205a94137fa38c3dbe936ea94350c8f334 /cpan/File-Fetch | |
parent | e66820012d29519f903709f005e56a2c334ae183 (diff) | |
download | perl-eee47ba661717bca7751443be1b6ac8f8f64585a.tar.gz |
Update File-Fetch to CPAN version 0.32
[DELTA]
Changes for 0.32 Mon Jan 17 10:26:40 2011
=================================================
* Added support for HTTP::Tiny
Diffstat (limited to 'cpan/File-Fetch')
-rw-r--r-- | cpan/File-Fetch/lib/File/Fetch.pm | 45 | ||||
-rw-r--r-- | cpan/File-Fetch/t/01_File-Fetch.t | 2 |
2 files changed, 44 insertions, 3 deletions
diff --git a/cpan/File-Fetch/lib/File/Fetch.pm b/cpan/File-Fetch/lib/File/Fetch.pm index c864b9158e..5d0a51df16 100644 --- a/cpan/File-Fetch/lib/File/Fetch.pm +++ b/cpan/File-Fetch/lib/File/Fetch.pm @@ -22,7 +22,7 @@ use vars qw[ $VERBOSE $PREFER_BIN $FROM_EMAIL $USER_AGENT $FTP_PASSIVE $TIMEOUT $DEBUG $WARN ]; -$VERSION = '0.30'; +$VERSION = '0.32'; $VERSION = eval $VERSION; # avoid warnings with development releases $PREFER_BIN = 0; # XXX TODO implement $FROM_EMAIL = 'File-Fetch@example.com'; @@ -36,7 +36,7 @@ $WARN = 1; ### methods available to fetch the file depending on the scheme $METHODS = { - http => [ qw|lwp httplite wget curl lftp fetch lynx iosock| ], + http => [ qw|lwp httptiny wget curl lftp fetch httplite lynx iosock| ], ftp => [ qw|lwp netftp wget curl lftp fetch ncftp ftp| ], file => [ qw|lwp lftp file| ], rsync => [ qw|rsync| ] @@ -584,6 +584,46 @@ sub _lwp_fetch { } } +### HTTP::Tiny fetching ### +sub _httptiny_fetch { + my $self = shift; + my %hash = @_; + + my ($to); + my $tmpl = { + to => { required => 1, store => \$to } + }; + check( $tmpl, \%hash ) or return; + + my $use_list = { + 'HTTP::Tiny' => '0.008', + + }; + + if( can_load(modules => $use_list) ) { + + my $uri = $self->uri; + + my $http = HTTP::Tiny->new( ( $TIMEOUT ? ( timeout => $TIMEOUT ) : () ) ); + + my $rc = $http->mirror( $uri, $to ); + + unless ( $rc->{success} ) { + + return $self->_error(loc( "Fetch failed! HTTP response: %1 [%2]", + $rc->{status}, $rc->{reason} ) ); + + } + + return $to; + + } + else { + $METHOD_FAIL->{'httptiny'} = 1; + return; + } +} + ### HTTP::Lite fetching ### sub _httplite_fetch { my $self = shift; @@ -1523,6 +1563,7 @@ the $BLACKLIST, $METHOD_FAIL and other internal functions. LWP => lwp HTTP::Lite => httplite + HTTP::Tiny => httptiny Net::FTP => netftp wget => wget lynx => lynx diff --git a/cpan/File-Fetch/t/01_File-Fetch.t b/cpan/File-Fetch/t/01_File-Fetch.t index 7a79f6daac..c780de1f88 100644 --- a/cpan/File-Fetch/t/01_File-Fetch.t +++ b/cpan/File-Fetch/t/01_File-Fetch.t @@ -179,7 +179,7 @@ for my $entry (@map) { 'http://www.cpan.org/index.html?q=1', 'http://www.cpan.org/index.html?q=1&y=2', ) { - for (qw[lwp httplite wget curl lftp fetch lynx iosock]) { + for (qw[lwp httptiny wget curl lftp fetch lynx httplite iosock]) { _fetch_uri( http => $uri, $_ ); } } |