Skip to content

Commit 97f7af2

Browse files
bingosjkeenan
authored andcommitted
cpan/File-Fetch - Update to version 1.08
1.08 Mon Apr 28 17:06:58 2025 * Switched from httpbin.org to httpbingo.org 1.06 Mon Apr 28 16:49:13 2025 * httpbin.org is being a bit unreliable at the moment and highlighted that lftp is like the little engine that could and it will keep trying and trying. Added restrictions to how many times it will retry.
1 parent 5939c4d commit 97f7af2

File tree

4 files changed

+47
-24
lines changed

4 files changed

+47
-24
lines changed

MANIFEST

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ cpan/ExtUtils-PL2Bat/lib/ExtUtils/PL2Bat.pm Implement pl2bat
11321132
cpan/ExtUtils-PL2Bat/t/make_executable.t Tests if ExtUtils::PL2Bat makes bat files that are executable
11331133
cpan/File-Fetch/lib/File/Fetch.pm File::Fetch
11341134
cpan/File-Fetch/t/01_File-Fetch.t File::Fetch tests
1135-
cpan/File-Fetch/t/null_subclass.t
1135+
cpan/File-Fetch/t/null_subclass.t Test file related to File::Fetch
11361136
cpan/File-Path/lib/File/Path.pm Do things like 'mkdir -p' and 'rm -r'
11371137
cpan/File-Path/t/FilePathTest.pm See if File::Path works
11381138
cpan/File-Path/t/Path.t See if File::Path works

Porting/Maintainers.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,8 @@ package Maintainers;
533533
},
534534

535535
'File::Fetch' => {
536-
'DISTRIBUTION' => 'BINGOS/File-Fetch-1.04.tar.gz',
536+
'DISTRIBUTION' => 'BINGOS/File-Fetch-1.08.tar.gz',
537+
'SYNCINFO' => 'jkeenan on Thu May 1 07:12:12 2025',
537538
'FILES' => q[cpan/File-Fetch],
538539
},
539540

cpan/File-Fetch/lib/File/Fetch.pm

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package File::Fetch;
22

33
use strict;
4+
use warnings;
45
use FileHandle;
56
use File::Temp;
67
use File::Copy;
@@ -22,7 +23,7 @@ use vars qw[ $VERBOSE $PREFER_BIN $FROM_EMAIL $USER_AGENT
2223
$FTP_PASSIVE $TIMEOUT $DEBUG $WARN $FORCEIPV4
2324
];
2425

25-
$VERSION = '1.04';
26+
$VERSION = '1.08';
2627
$VERSION = eval $VERSION; # avoid warnings with development releases
2728
$PREFER_BIN = 0; # XXX TODO implement
2829
$FROM_EMAIL = 'File-Fetch@example.com';
@@ -39,7 +40,7 @@ $FORCEIPV4 = 0;
3940
### methods available to fetch the file depending on the scheme
4041
$METHODS = {
4142
http => [ qw|lwp httptiny wget curl lftp fetch httplite lynx iosock| ],
42-
https => [ qw|lwp wget curl| ],
43+
https => [ qw|lwp httptiny wget curl| ],
4344
ftp => [ qw|lwp netftp wget curl lftp fetch ncftp ftp| ],
4445
file => [ qw|lwp lftp file| ],
4546
rsync => [ qw|rsync| ],
@@ -58,7 +59,7 @@ use constant ON_VMS => ($^O eq 'VMS');
5859
use constant ON_UNIX => (!ON_WIN);
5960
use constant HAS_VOL => (ON_WIN);
6061
use constant HAS_SHARE => (ON_WIN);
61-
use constant HAS_FETCH => ( $^O =~ m!^(freebsd|netbsd|dragonfly)$! );
62+
use constant HAS_FETCH => ( $^O =~ m!^(freebsd|netbsd|dragonfly|midnightbsd)$! );
6263

6364
=pod
6465
@@ -400,9 +401,12 @@ sub _parse_uri {
400401
### rebuild the path from the leftover parts;
401402
$href->{path} = join '/', '', splice( @parts, $index, $#parts );
402403

403-
} else {
404+
} elsif ( $href->{scheme} eq 'http' || $href->{scheme} eq 'https' ) {
404405
### using anything but qw() in hash slices may produce warnings
405406
### in older perls :-(
407+
@{$href}{ qw(userinfo host path) } = $uri =~ m|(?:([^\@:]*:[^\:\@]*)@)?([^/]*)(/.*)?$|s;
408+
$href->{path} = '/' unless defined $href->{path};
409+
} else {
406410
@{$href}{ qw(userinfo host path) } = $uri =~ m|(?:([^\@:]*:[^\:\@]*)@)?([^/]*)(/.*)$|s;
407411
}
408412

@@ -491,7 +495,9 @@ sub fetch {
491495
next if grep { lc $_ eq $method } @$BLACKLIST;
492496

493497
### method is known to fail ###
494-
next if $METHOD_FAIL->{$method};
498+
next if ref $METHOD_FAIL->{$method}
499+
? $METHOD_FAIL->{$method}{$self->scheme}
500+
: $METHOD_FAIL->{$method};
495501

496502
### there's serious issues with IPC::Run and quoting of command
497503
### line arguments. using quotes in the wrong place breaks things,
@@ -569,17 +575,24 @@ sub _lwp_fetch {
569575

570576
};
571577

572-
if ($self->scheme eq 'https') {
573-
$use_list->{'LWP::Protocol::https'} = '0';
574-
}
575-
576578
### Fix CVE-2016-1238 ###
577579
local $Module::Load::Conditional::FORCE_SAFE_INC = 1;
578580
unless( can_load( modules => $use_list ) ) {
579581
$METHOD_FAIL->{'lwp'} = 1;
580582
return;
581583
}
582584

585+
if ($self->scheme eq 'https') {
586+
my $https_use_list = {
587+
'LWP::Protocol::https' => '0.0',
588+
};
589+
590+
unless ( can_load(modules => $https_use_list) ) {
591+
$METHOD_FAIL->{'lwp'} = { 'https' => 1 };
592+
return;
593+
}
594+
}
595+
583596
### setup the uri object
584597
my $uri = URI->new( File::Spec::Unix->catfile(
585598
$self->path, $self->file
@@ -638,6 +651,10 @@ sub _httptiny_fetch {
638651
$METHOD_FAIL->{'httptiny'} = 1;
639652
return;
640653
}
654+
if ( $self->scheme eq 'https' && !HTTP::Tiny->can_ssl ) {
655+
$METHOD_FAIL->{'httptiny'} = 1;
656+
return;
657+
}
641658

642659
my $uri = $self->uri;
643660

@@ -962,6 +979,9 @@ sub _lftp_fetch {
962979
### if a timeout is set, add it ###
963980
$str .= "set net:timeout $TIMEOUT;\n" if $TIMEOUT;
964981

982+
### lftp can get stuck in a loop of retries without this
983+
$str .= "set net:reconnect-interval-base 5;\nset net:max-retries 2;\n";
984+
965985
### run passive if specified ###
966986
$str .= "set ftp:passive-mode 1;\n" if $FTP_PASSIVE;
967987

cpan/File-Fetch/t/01_File-Fetch.t

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
BEGIN { chdir 't' if -d 't' };
22

33
use strict;
4+
use warnings;
45
use lib '../lib';
56

67
use Test::More 'no_plan';
@@ -16,7 +17,9 @@ use_ok('File::Fetch');
1617
$File::Fetch::DEBUG = $File::Fetch::DEBUG = 1 if $ARGV[0];
1718
$IPC::Cmd::DEBUG = $IPC::Cmd::DEBUG = 1 if $ARGV[0];
1819

19-
$File::Fetch::FORCEIPV4=1;
20+
$File::Fetch::FORCEIPV4 = $File::Fetch::FORCEIPV4 = 1;
21+
22+
$File::Fetch::TIMEOUT = $File::Fetch::TIMEOUT = 30;
2023

2124
unless( $ENV{PERL_CORE} ) {
2225
warn qq[
@@ -77,6 +80,12 @@ my @map = (
7780
path => '/tmp/',
7881
file => 'index.txt',
7982
},
83+
{ uri => 'http://localhost', # non-canonical URI
84+
scheme => 'http',
85+
host => 'localhost',
86+
path => '/', # default path is '/'
87+
file => '',
88+
},
8089

8190
### only test host part, the rest is OS dependant
8291
{ uri => 'file://localhost/tmp/index.txt',
@@ -195,14 +204,15 @@ for my $entry (@map) {
195204
### Heuristics
196205
{
197206
require IO::Socket::INET;
198-
my $sock = IO::Socket::INET->new( PeerAddr => 'httpbin.org', PeerPort => 80, Timeout => 20 )
207+
my $sock = IO::Socket::INET->new( PeerAddr => 'httpbingo.org', PeerPort => 80, Timeout => 20 )
199208
or $heuristics{http} = 0;
200209
}
201210

202211
### http:// tests ###
203-
{ for my $uri ( 'http://httpbin.org/html',
204-
'http://httpbin.org/response-headers?q=1',
205-
'http://httpbin.org/response-headers?q=1&y=2',
212+
{ for my $uri ( 'http://httpbingo.org',
213+
'http://httpbingo.org/html',
214+
'http://httpbingo.org/response-headers?q=1',
215+
'http://httpbingo.org/response-headers?q=1&y=2',
206216
#'http://www.cpan.org/index.html?q=1&y=2',
207217
#'http://user:passwd@httpbin.org/basic-auth/user/passwd',
208218
) {
@@ -300,11 +310,3 @@ sub _fetch_uri {
300310
}}
301311
}
302312
}
303-
304-
305-
306-
307-
308-
309-
310-

0 commit comments

Comments
 (0)