]> granicus.if.org Git - php/commitdiff
Bail on no HTTP.php present in the system
authorTomas V.V.Cox <cox@php.net>
Sun, 21 Apr 2002 01:34:49 +0000 (01:34 +0000)
committerTomas V.V.Cox <cox@php.net>
Sun, 21 Apr 2002 01:34:49 +0000 (01:34 +0000)
Let "pear download" act ala wget

pear/PEAR/Command/Remote.php

index b754055d0a772791b4e5c7ca18296ace4d5ce2f6..1b2de8942d56182d975a073177d8fd7d5a69e087 100644 (file)
@@ -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;
                 }