Index: trunk/phase3/tests/HttpTest.php |
— | — | @@ -65,26 +65,26 @@ |
66 | 66 | function testInstantiation() { |
67 | 67 | Http::$httpEngine = false; |
68 | 68 | |
69 | | - $r = new HttpRequest("http://www.example.com/"); |
| 69 | + $r = HttpRequest::factory("http://www.example.com/"); |
70 | 70 | if ( self::$has_curl ) { |
71 | | - $this->isInstanceOf( $r, 'CurlHttpRequest' ); |
| 71 | + $this->assertThat($r, $this->isInstanceOf( 'CurlHttpRequest' )); |
72 | 72 | } else { |
73 | | - $this->isInstanceOf( $r, 'PhpHttpRequest' ); |
| 73 | + $this->assertThat($r, $this->isInstanceOf( 'PhpHttpRequest' )); |
74 | 74 | } |
75 | 75 | unset($r); |
76 | 76 | |
77 | 77 | Http::$httpEngine = 'php'; |
78 | | - $r = new HttpRequest("http://www.example.com/"); |
79 | | - $this->isInstanceOf( $r, 'PhpHttpRequest' ); |
| 78 | + $r = HttpRequest::factory("http://www.example.com/"); |
| 79 | + $this->assertThat($r, $this->isInstanceOf( 'PhpHttpRequest' )); |
80 | 80 | unset($r); |
81 | 81 | |
82 | 82 | if( !self::$has_curl ) { |
83 | 83 | $this->setExpectedException( 'MWException' ); |
84 | 84 | } |
85 | 85 | Http::$httpEngine = 'curl'; |
86 | | - $r = new HttpRequest("http://www.example.com/"); |
| 86 | + $r = HttpRequest::factory("http://www.example.com/"); |
87 | 87 | if( self::$has_curl ) { |
88 | | - $this->isInstanceOf( $r, 'CurlHttpRequest' ); |
| 88 | + $this->assertThat($r, $this->isInstanceOf( 'CurlHttpRequest' )); |
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
Index: trunk/phase3/includes/HttpFunctions.php |
— | — | @@ -171,7 +171,7 @@ |
172 | 172 | * Generate a new request object |
173 | 173 | * @see HttpRequest::__construct |
174 | 174 | */ |
175 | | - public static function factory( $url, $options ) { |
| 175 | + public static function factory( $url, $options = null ) { |
176 | 176 | if ( !Http::$httpEngine ) { |
177 | 177 | Http::$httpEngine = function_exists( 'curl_init' ) ? 'curl' : 'php'; |
178 | 178 | } elseif ( Http::$httpEngine == 'curl' && !function_exists( 'curl_init' ) ) { |
— | — | @@ -315,10 +315,6 @@ |
316 | 316 | if ( !$this->status->isOK() ) { |
317 | 317 | return $this->status; |
318 | 318 | } |
319 | | - |
320 | | - // A lot of the action up front should probably be in |
321 | | - // set* methods, but we'll leave that for another time. |
322 | | - |
323 | 319 | $this->curlOptions[CURLOPT_PROXY] = $this->proxy; |
324 | 320 | $this->curlOptions[CURLOPT_TIMEOUT] = $this->timeout; |
325 | 321 | $this->curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0; |
— | — | @@ -387,9 +383,6 @@ |
388 | 384 | return $this->status; |
389 | 385 | } |
390 | 386 | |
391 | | - // A lot of the action up front should probably be in |
392 | | - // set* methods, but we'll leave that for another time. |
393 | | - |
394 | 387 | $this->reqHeaders['Accept'] = "*/*"; |
395 | 388 | if ( $this->method == 'POST' ) { |
396 | 389 | // Required for HTTP 1.0 POSTs |