From 13f7ec437411b4d114880b0e6cb1b0b6b3851620 Mon Sep 17 00:00:00 2001 From: "Tomas V.V.Cox" Date: Sun, 21 Apr 2002 01:34:49 +0000 Subject: Bail on no HTTP.php present in the system Let "pear download" act ala wget --- pear/PEAR/Command/Remote.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'pear/PEAR/Command/Remote.php') diff --git a/pear/PEAR/Command/Remote.php b/pear/PEAR/Command/Remote.php index b754055d0a..1b2de8942d 100644 --- a/pear/PEAR/Command/Remote.php +++ b/pear/PEAR/Command/Remote.php @@ -95,13 +95,20 @@ class PEAR_Command_Remote extends PEAR_Command_Common if (!extension_loaded("zlib")) { $pkgfile .= '?uncompress=yes'; } - include_once 'HTTP.php'; + if (!@include_once 'HTTP.php') { + return $this->raiseError('The "download" command needs HTTP.php to be installed'); + } $headers = HTTP::head($pkgfile); - if (PEAR::isError($headers)|| !isset($headers['Content-disposition'])) { - return $this->raiseError("Could not retrieve remote file information"); + if (PEAR::isError($headers)) { + $msg = $headers->getMessage(); + return $this->raiseError("Could not retrieve remote file information ($msg)"); + } + if (isset($headers['Content-disposition'])) { + preg_match('|filename="(.*)"$|', $headers['Content-disposition'], $matches); + $fname = $matches[1]; + } else { + $fname = basename($pkgfile); } - preg_match('|filename="(.*)"$|', $headers['Content-disposition'], $matches); - $fname = $matches[1]; if (!$wp = @fopen($pkgfile, 'wb')) { $failmsg = "Could not download $pkgfile"; break; } -- cgit v1.2.1