}
if((int)$this->respStatus !== 200) {
- $this->status->fatal("http-bad-status", explode(" ", $this->respStatus, 2));
+ list( $code, $message ) = explode(" ", $this->respStatus, 2);
+ $this->status->fatal("http-bad-status", $code, $message );
}
+
$this->parseCookies();
}
$options['method'] = $this->method;
$options['timeout'] = $this->timeout;
+ $options['ignore_errors'] = true; /* the only way to get 404s, etc */
$options['header'] = implode("\r\n", $this->getHeaderList());
// Note that at some future point we may want to support
// HTTP/1.1, but we'd have to write support for chunking
}
$this->headerList = $result['wrapper_data'];
- while ( !feof( $fh ) ) {
- $buf = fread( $fh, 8192 );
- if ( $buf === false ) {
- $this->status->fatal( 'http-read-error' );
- break;
- }
- if ( strlen( $buf ) ) {
- call_user_func( $this->callback, $fh, $buf );
+ $this->parseHeader();
+ if($this->status->isOK()) {
+ while ( !feof( $fh ) ) {
+ $buf = fread( $fh, 8192 );
+ if ( $buf === false ) {
+ $this->status->fatal( 'http-read-error' );
+ break;
+ }
+ if ( strlen( $buf ) ) {
+ call_user_func( $this->callback, $fh, $buf );
+ }
}
}
fclose( $fh );
- $this->parseHeader();
return $this->status;
}
}
$r = HTTP::get( "http://www.example.com/this-file-does-not-exist", $timeout);
$this->assertFalse($r, "False on 404s");
+
+
+ $r = HttpRequest::factory( "http://www.example.com/this-file-does-not-exist" );
+ $er = $r->execute();
+ $this->assertRegexp("/404 Not Found/", $er->getWikiText());
}
function testFailureDefault() {
Http::$httpEngine = 'curl';
self::runCookieRequests();
}
-
}
\ No newline at end of file