-
- if ( !isset( $options['logger'] ) ) {
- $options['logger'] = LoggerFactory::getInstance( 'http' );
- }
-
- switch ( Http::$httpEngine ) {
- case 'curl':
- return new CurlHttpRequest( $url, $options, $caller, Profiler::instance() );
- 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 ' .
- 'http://php.net/curl.'
- );
- }
- return new PhpHttpRequest( $url, $options, $caller, Profiler::instance() );
- default:
- throw new DomainException( __METHOD__ . ': The setting of Http::$httpEngine is not valid.' );
- }
+ return \MediaWiki\MediaWikiServices::getInstance()
+ ->getHttpRequestFactory()
+ ->create( $url, $options, $caller );