From: Tomas V.V.Cox Date: Sun, 21 Apr 2002 01:34:49 +0000 (+0000) Subject: Bail on no HTTP.php present in the system X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~528 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13f7ec437411b4d114880b0e6cb1b0b6b3851620;p=php Bail on no HTTP.php present in the system Let "pear download" act ala wget --- 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; }