* Generate a new request object
* @see HttpRequest::__construct
*/
- public static function factory( $url, $options ) {
+ public static function factory( $url, $options = null ) {
if ( !Http::$httpEngine ) {
Http::$httpEngine = function_exists( 'curl_init' ) ? 'curl' : 'php';
} elseif ( Http::$httpEngine == 'curl' && !function_exists( 'curl_init' ) ) {
if ( !$this->status->isOK() ) {
return $this->status;
}
-
- // A lot of the action up front should probably be in
- // set* methods, but we'll leave that for another time.
-
$this->curlOptions[CURLOPT_PROXY] = $this->proxy;
$this->curlOptions[CURLOPT_TIMEOUT] = $this->timeout;
$this->curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
return $this->status;
}
- // A lot of the action up front should probably be in
- // set* methods, but we'll leave that for another time.
-
$this->reqHeaders['Accept'] = "*/*";
if ( $this->method == 'POST' ) {
// Required for HTTP 1.0 POSTs
function testInstantiation() {
Http::$httpEngine = false;
- $r = new HttpRequest("http://www.example.com/");
+ $r = HttpRequest::factory("http://www.example.com/");
if ( self::$has_curl ) {
- $this->isInstanceOf( $r, 'CurlHttpRequest' );
+ $this->assertThat($r, $this->isInstanceOf( 'CurlHttpRequest' ));
} else {
- $this->isInstanceOf( $r, 'PhpHttpRequest' );
+ $this->assertThat($r, $this->isInstanceOf( 'PhpHttpRequest' ));
}
unset($r);
Http::$httpEngine = 'php';
- $r = new HttpRequest("http://www.example.com/");
- $this->isInstanceOf( $r, 'PhpHttpRequest' );
+ $r = HttpRequest::factory("http://www.example.com/");
+ $this->assertThat($r, $this->isInstanceOf( 'PhpHttpRequest' ));
unset($r);
if( !self::$has_curl ) {
$this->setExpectedException( 'MWException' );
}
Http::$httpEngine = 'curl';
- $r = new HttpRequest("http://www.example.com/");
+ $r = HttpRequest::factory("http://www.example.com/");
if( self::$has_curl ) {
- $this->isInstanceOf( $r, 'CurlHttpRequest' );
+ $this->assertThat($r, $this->isInstanceOf( 'CurlHttpRequest' ));
}
}