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;
}