]> granicus.if.org Git - php/commitdiff
make downloadHttp() detect HTTP errors
authorTomas V.V.Cox <cox@php.net>
Wed, 15 May 2002 11:23:01 +0000 (11:23 +0000)
committerTomas V.V.Cox <cox@php.net>
Wed, 15 May 2002 11:23:01 +0000 (11:23 +0000)
pear/PEAR/Common.php

index bb67f4c145397ae02448d1fa3efd4aae1ca4545f..67206461783d9a589c3baa4eb308ae0e264ac086 100644 (file)
@@ -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']) &&