Index: trunk/phase3/maintenance/tests/HttpTest.php |
— | — | @@ -112,6 +112,11 @@ |
113 | 113 | |
114 | 114 | $r = HTTP::get( "http://www.example.com/this-file-does-not-exist", $timeout); |
115 | 115 | $this->assertFalse($r, "False on 404s"); |
| 116 | + |
| 117 | + |
| 118 | + $r = HttpRequest::factory( "http://www.example.com/this-file-does-not-exist" ); |
| 119 | + $er = $r->execute(); |
| 120 | + $this->assertRegexp("/404 Not Found/", $er->getWikiText()); |
116 | 121 | } |
117 | 122 | |
118 | 123 | function testFailureDefault() { |
— | — | @@ -550,5 +555,4 @@ |
551 | 556 | Http::$httpEngine = 'curl'; |
552 | 557 | self::runCookieRequests(); |
553 | 558 | } |
554 | | - |
555 | 559 | } |
\ No newline at end of file |
Index: trunk/phase3/includes/HttpFunctions.php |
— | — | @@ -334,8 +334,10 @@ |
335 | 335 | } |
336 | 336 | |
337 | 337 | if((int)$this->respStatus !== 200) { |
338 | | - $this->status->fatal("http-bad-status", explode(" ", $this->respStatus, 2)); |
| 338 | + list( $code, $message ) = explode(" ", $this->respStatus, 2); |
| 339 | + $this->status->fatal("http-bad-status", $code, $message ); |
339 | 340 | } |
| 341 | + |
340 | 342 | $this->parseCookies(); |
341 | 343 | } |
342 | 344 | |
— | — | @@ -753,6 +755,7 @@ |
754 | 756 | |
755 | 757 | $options['method'] = $this->method; |
756 | 758 | $options['timeout'] = $this->timeout; |
| 759 | + $options['ignore_errors'] = true; /* the only way to get 404s, etc */ |
757 | 760 | $options['header'] = implode("\r\n", $this->getHeaderList()); |
758 | 761 | // Note that at some future point we may want to support |
759 | 762 | // HTTP/1.1, but we'd have to write support for chunking |
— | — | @@ -787,19 +790,21 @@ |
788 | 791 | } |
789 | 792 | $this->headerList = $result['wrapper_data']; |
790 | 793 | |
791 | | - while ( !feof( $fh ) ) { |
792 | | - $buf = fread( $fh, 8192 ); |
793 | | - if ( $buf === false ) { |
794 | | - $this->status->fatal( 'http-read-error' ); |
795 | | - break; |
| 794 | + $this->parseHeader(); |
| 795 | + if($this->status->isOK()) { |
| 796 | + while ( !feof( $fh ) ) { |
| 797 | + $buf = fread( $fh, 8192 ); |
| 798 | + if ( $buf === false ) { |
| 799 | + $this->status->fatal( 'http-read-error' ); |
| 800 | + break; |
| 801 | + } |
| 802 | + if ( strlen( $buf ) ) { |
| 803 | + call_user_func( $this->callback, $fh, $buf ); |
| 804 | + } |
796 | 805 | } |
797 | | - if ( strlen( $buf ) ) { |
798 | | - call_user_func( $this->callback, $fh, $buf ); |
799 | | - } |
800 | 806 | } |
801 | 807 | fclose( $fh ); |
802 | 808 | |
803 | | - $this->parseHeader(); |
804 | 809 | return $this->status; |
805 | 810 | } |
806 | 811 | } |