HttpRequestFactory.php (mediawiki-1.31.1) | : | HttpRequestFactory.php (mediawiki-1.32.0) | ||
---|---|---|---|---|
skipping to change at line 48 | skipping to change at line 48 | |||
* @param array $options (optional) extra params to pass (see Http::reque st()) | * @param array $options (optional) extra params to pass (see Http::reque st()) | |||
* @param string $caller The method making this request, for profiling | * @param string $caller The method making this request, for profiling | |||
* @throws DomainException | * @throws DomainException | |||
* @return MWHttpRequest | * @return MWHttpRequest | |||
* @see MWHttpRequest::__construct | * @see MWHttpRequest::__construct | |||
*/ | */ | |||
public function create( $url, array $options = [], $caller = __METHOD__ ) { | public function create( $url, array $options = [], $caller = __METHOD__ ) { | |||
if ( !Http::$httpEngine ) { | if ( !Http::$httpEngine ) { | |||
Http::$httpEngine = function_exists( 'curl_init' ) ? 'cur l' : 'php'; | Http::$httpEngine = function_exists( 'curl_init' ) ? 'cur l' : 'php'; | |||
} elseif ( Http::$httpEngine == 'curl' && !function_exists( 'curl _init' ) ) { | } elseif ( Http::$httpEngine == 'curl' && !function_exists( 'curl _init' ) ) { | |||
throw new DomainException( __METHOD__ . ': curl (http://p | throw new DomainException( __METHOD__ . ': curl (https:// | |||
hp.net/curl) is not installed, but' . | secure.php.net/curl) is not ' . | |||
' Http::$httpEngine is set to "curl"' ); | 'installed, but Http::$httpEngine is set to "curl"' ); | |||
} | } | |||
if ( !isset( $options['logger'] ) ) { | if ( !isset( $options['logger'] ) ) { | |||
$options['logger'] = LoggerFactory::getInstance( 'http' ) ; | $options['logger'] = LoggerFactory::getInstance( 'http' ) ; | |||
} | } | |||
switch ( Http::$httpEngine ) { | switch ( Http::$httpEngine ) { | |||
case 'curl': | case 'curl': | |||
return new CurlHttpRequest( $url, $options, $call er, Profiler::instance() ); | return new CurlHttpRequest( $url, $options, $call er, Profiler::instance() ); | |||
case 'php': | case 'php': | |||
if ( !wfIniGetBool( 'allow_url_fopen' ) ) { | if ( !wfIniGetBool( 'allow_url_fopen' ) ) { | |||
throw new DomainException( __METHOD__ . ' : allow_url_fopen ' . | throw new DomainException( __METHOD__ . ' : allow_url_fopen ' . | |||
'needs to be enabled for pure PHP http requests to ' . | 'needs to be enabled for pure PHP http requests to ' . | |||
'work. If possible, curl should be use d instead. See ' . | 'work. If possible, curl should be use d instead. See ' . | |||
'http://php.net/curl.' | 'https://secure.php.net/curl.' | |||
); | ); | |||
} | } | |||
return new PhpHttpRequest( $url, $options, $calle r, Profiler::instance() ); | return new PhpHttpRequest( $url, $options, $calle r, Profiler::instance() ); | |||
default: | default: | |||
throw new DomainException( __METHOD__ . ': The se tting of Http::$httpEngine is not valid.' ); | throw new DomainException( __METHOD__ . ': The se tting of Http::$httpEngine is not valid.' ); | |||
} | } | |||
} | } | |||
/** | /** | |||
* Simple function to test if we can make any sort of requests at all, us ing | * Simple function to test if we can make any sort of requests at all, us ing | |||
End of changes. 2 change blocks. | ||||
4 lines changed or deleted | 4 lines changed or added |