diff options
| author | Tomas V.V.Cox <cox@php.net> | 2002-04-21 01:34:49 +0000 |
|---|---|---|
| committer | Tomas V.V.Cox <cox@php.net> | 2002-04-21 01:34:49 +0000 |
| commit | 13f7ec437411b4d114880b0e6cb1b0b6b3851620 (patch) | |
| tree | 669a823031f5305fb6e343f4343f27e73220e502 /pear/PEAR/Command/Remote.php | |
| parent | 929e8f81e32f6bdc6a053423b05976d5a9a89689 (diff) | |
| download | php-git-13f7ec437411b4d114880b0e6cb1b0b6b3851620.tar.gz | |
Bail on no HTTP.php present in the system
Let "pear download" act ala wget
Diffstat (limited to 'pear/PEAR/Command/Remote.php')
| -rw-r--r-- | pear/PEAR/Command/Remote.php | 17 |
1 files changed, 12 insertions, 5 deletions
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; } |
