summaryrefslogtreecommitdiffstats
path: root/perl-install/install/http.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/install/http.pm')
-rw-r--r--perl-install/install/http.pm19
1 files changed, 18 insertions, 1 deletions
diff --git a/perl-install/install/http.pm b/perl-install/install/http.pm
index 75d026d0d..bf59c273b 100644
--- a/perl-install/install/http.pm
+++ b/perl-install/install/http.pm
@@ -14,6 +14,23 @@ sub getFile {
my ($_size, $fh) = get_file_and_size($url) or return;
$fh;
}
+
+sub parse_url {
+ my ($url) = @_;
+ $url =~ m,^(?:http|ftp)://([^/:]+)(?::(\d+))?(/\S*)?$,;
+}
+
+sub get_file_and_size_ {
+ my ($f, $url) = @_;
+
+ if ($f =~ m!^/!) {
+ my ($host, $port, $_path) = parse_url($url);
+ get_file_and_size("http://$host" . ($port ? ":$port" : '') . $f);
+ } else {
+ get_file_and_size("$url/$f");
+ }
+}
+
sub get_file_and_size {
local ($^W) = 0;
@@ -21,7 +38,7 @@ sub get_file_and_size {
$sock->close if $sock;
# can be used for ftp urls (with http proxy)
- my ($host, $port, $path) = $url =~ m,^(?:http|ftp)://([^/:]+)(?::(\d+))?(/\S*)?$,;
+ my ($host, $port, $path) = parse_url($url);
defined $host or return undef;
my $use_http_proxy = $ENV{PROXY} && $ENV{PROXYPORT};