From: Tomas V.V.Cox Date: Wed, 15 May 2002 11:23:01 +0000 (+0000) Subject: make downloadHttp() detect HTTP errors X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~32 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fd5b0fb50ad5039a1e12add3b889ff2fa2153c93;p=php make downloadHttp() detect HTTP errors --- diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php index bb67f4c145..6720646178 100644 --- a/pear/PEAR/Common.php +++ b/pear/PEAR/Common.php @@ -1395,6 +1395,10 @@ class PEAR_Common extends PEAR while (trim($line = fgets($fp, 1024))) { if (preg_match('/^([^:]+):\s+(.*)\s*$/', $line, $matches)) { $headers[strtolower($matches[1])] = trim($matches[2]); + } elseif (preg_match('|^HTTP/1.[01] ([0-9]{3}) |', $line, $matches)) { + if ($matches[1] != 200) { + return PEAR::raiseError("File http://$host:$port$path not valid (received: $line)"); + } } } if (isset($headers['content-disposition']) &&