Index: trunk/phase3/maintenance/tests/HttpTest.php |
— | — | @@ -109,6 +109,9 @@ |
110 | 110 | $this->assertLessThan($timeout+2, $end_time - $start_time, |
111 | 111 | "Request took less than {$timeout}s via ".Http::$httpEngine); |
112 | 112 | $this->assertEquals($r, false, "false -- what we get on error from Http::get()"); |
| 113 | + |
| 114 | + $r = HTTP::get( "http://www.example.com/this-file-does-not-exist", $timeout); |
| 115 | + $this->assertFalse($r, "False on 404s"); |
113 | 116 | } |
114 | 117 | |
115 | 118 | function testFailureDefault() { |
Index: trunk/phase3/includes/HttpFunctions.php |
— | — | @@ -140,7 +140,7 @@ |
141 | 141 | |
142 | 142 | protected $headerList = array(); |
143 | 143 | protected $respVersion = "0.9"; |
144 | | - protected $respStatus = "0.1"; |
| 144 | + protected $respStatus = "200 Ok"; |
145 | 145 | protected $respHeaders = array(); |
146 | 146 | |
147 | 147 | public $status; |
— | — | @@ -258,8 +258,8 @@ |
259 | 259 | |
260 | 260 | if( $this->cookieJar ) { |
261 | 261 | $this->reqHeaders['Cookie'] = |
262 | | - $this->cookieJar->serializeToHttpRequest($this->parsedURL['path'], |
263 | | - $this->parsedURL['host']); |
| 262 | + $this->cookieJar->serializeToHttpRequest($this->parsedUrl['path'], |
| 263 | + $this->parsedUrl['host']); |
264 | 264 | } |
265 | 265 | foreach($this->reqHeaders as $name => $value) { |
266 | 266 | $list[] = "$name: $value"; |
— | — | @@ -333,6 +333,9 @@ |
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
| 337 | + if((int)$this->respStatus !== 200) { |
| 338 | + $this->status->fatal('Not Ok'); |
| 339 | + } |
337 | 340 | $this->parseCookies(); |
338 | 341 | } |
339 | 342 | |
— | — | @@ -707,6 +710,7 @@ |
708 | 711 | |
709 | 712 | curl_close( $curlHandle ); |
710 | 713 | |
| 714 | + $this->parseHeader(); |
711 | 715 | return $this->status; |
712 | 716 | } |
713 | 717 | } |
— | — | @@ -720,7 +724,7 @@ |
721 | 725 | |
722 | 726 | public function execute() { |
723 | 727 | if ( $this->parsedUrl['scheme'] != 'http' ) { |
724 | | - $this->status->fatal( 'http-invalid-scheme', $this->parsedURL['scheme'] ); |
| 728 | + $this->status->fatal( 'http-invalid-scheme', $this->parsedUrl['scheme'] ); |
725 | 729 | } |
726 | 730 | |
727 | 731 | parent::execute(); |
— | — | @@ -795,6 +799,7 @@ |
796 | 800 | } |
797 | 801 | fclose( $fh ); |
798 | 802 | |
| 803 | + $this->parseHeader(); |
799 | 804 | return $this->status; |
800 | 805 | } |
801 | 806 | } |