/**
* Constant values are from PHP 5.3.28 using cURL 7.24.0
- * @see https://secure.php.net/manual/en/curl.constants.php
+ * @see https://www.php.net/manual/en/curl.constants.php
*
* All constant values are present so that developers don’t need to remember
* to add them if added at a later date. The commented out constants were
// returns appropriate tester class here
public static function factory( $url, array $options = null, $caller = __METHOD__ ) {
if ( !Http::$httpEngine ) {
- Http::$httpEngine = function_exists( 'curl_init' ) ? 'curl' : 'php';
+ Http::$httpEngine = 'guzzle';
} elseif ( Http::$httpEngine == 'curl' && !function_exists( 'curl_init' ) ) {
- throw new DomainException( __METHOD__ . ': curl (https://secure.php.net/curl) is not ' .
+ throw new DomainException( __METHOD__ . ': curl (https://www.php.net/curl) is not ' .
'installed, but Http::$httpEngine is set to "curl"' );
}
switch ( Http::$httpEngine ) {
+ case 'guzzle':
+ return new GuzzleHttpRequestTester( $url, $options, $caller );
case 'curl':
return new CurlHttpRequestTester( $url, $options, $caller );
case 'php':
if ( !wfIniGetBool( 'allow_url_fopen' ) ) {
throw new DomainException( __METHOD__ .
': allow_url_fopen needs to be enabled for pure PHP HTTP requests to work. '
- . 'If possible, curl should be used instead. See https://secure.php.net/curl.' );
+ . 'If possible, curl should be used instead. See https://www.php.net/curl.' );
}
return new PhpHttpRequestTester( $url, $options, $caller );
}
}
+class GuzzleHttpRequestTester extends GuzzleHttpRequest {
+ function setRespHeaders( $name, $value ) {
+ $this->respHeaders[$name] = $value;
+ }
+}
+
class CurlHttpRequestTester extends CurlHttpRequest {
function setRespHeaders( $name, $value ) {
$this->respHeaders[$name] = $value;