MediaWiki REL1_34
MediaWiki\Http\HttpRequestFactory Class Reference

Factory creating MWHttpRequest objects. More...

Public Member Functions

 canMakeRequests ()
 Simple function to test if we can make any sort of requests at all, using cURL or fopen()
 
 create ( $url, array $options=[], $caller=__METHOD__)
 Generate a new MWHttpRequest object.
 
 get ( $url, array $options=[], $caller=__METHOD__)
 Simple wrapper for request( 'GET' ), parameters have same meaning as for request()
 
 getUserAgent ()
 
 post ( $url, array $options=[], $caller=__METHOD__)
 Simple wrapper for request( 'POST' ), parameters have same meaning as for request()
 
 request ( $method, $url, array $options=[], $caller=__METHOD__)
 Perform an HTTP request.
 

Detailed Description

Factory creating MWHttpRequest objects.

Definition at line 35 of file HttpRequestFactory.php.

Member Function Documentation

◆ canMakeRequests()

MediaWiki\Http\HttpRequestFactory::canMakeRequests ( )

Simple function to test if we can make any sort of requests at all, using cURL or fopen()

Returns
bool

Definition at line 95 of file HttpRequestFactory.php.

References wfIniGetBool().

◆ create()

MediaWiki\Http\HttpRequestFactory::create (   $url,
array  $options = [],
  $caller = __METHOD__ 
)

Generate a new MWHttpRequest object.

Parameters
string$urlUrl to use
array$optionsPossible keys for the array:
  • timeout Timeout length in seconds or 'default'
  • connectTimeout Timeout for connection, in seconds (curl only) or 'default'
  • postData An array of key-value pairs or a url-encoded form data
  • proxy The proxy to use. Otherwise it will use $wgHTTPProxy (if set) Otherwise it will use the environment variable "http_proxy" (if set)
  • noProxy Don't use any proxy at all. Takes precedence over proxy value(s).
  • sslVerifyHost Verify hostname against certificate
  • sslVerifyCert Verify SSL certificate
  • caInfo Provide CA information
  • maxRedirects Maximum number of redirects to follow (defaults to 5)
  • followRedirects Whether to follow redirects (defaults to false). Note: this should only be used when the target URL is trusted, to avoid attacks on intranet services accessible by HTTP.
  • userAgent A user agent, if you want to override the default MediaWiki/$wgVersion
  • logger A \Psr\Logger\LoggerInterface instance for debug logging
  • username Username for HTTP Basic Authentication
  • password Password for HTTP Basic Authentication
  • originalRequest Information about the original request (as a WebRequest object or an associative array with 'ip' and 'userAgent').

-param array{timeout?:int|string,connectTimeout?:int|string,postData?:array,proxy?:string,noProxy?:bool,sslVerifyHost?:bool,sslVerifyCert?:bool,caInfo?:string,maxRedirects?:int,followRedirects?:bool,userAgent?:string,method?:string,logger?:\Psr\Log\LoggerInterface,username?:string,password?:string,originalRequest?:\WebRequest|array{ip:string,userAgent:string}} $options

Parameters
string$callerThe method making this request, for profiling
Exceptions
RuntimeException
Returns
MWHttpRequest
See also
MWHttpRequest::__construct

Definition at line 69 of file HttpRequestFactory.php.

References Http\$httpEngine, and Profiler\instance().

Referenced by MediaWiki\Http\HttpRequestFactory\request().

◆ get()

MediaWiki\Http\HttpRequestFactory::get (   $url,
array  $options = [],
  $caller = __METHOD__ 
)

Simple wrapper for request( 'GET' ), parameters have same meaning as for request()

Since
1.34
Parameters
string$url
array$options
string$caller
Returns
string|null

Definition at line 145 of file HttpRequestFactory.php.

References MediaWiki\Http\HttpRequestFactory\request().

◆ getUserAgent()

MediaWiki\Http\HttpRequestFactory::getUserAgent ( )
Returns
string

Definition at line 165 of file HttpRequestFactory.php.

References $wgVersion.

◆ post()

MediaWiki\Http\HttpRequestFactory::post (   $url,
array  $options = [],
  $caller = __METHOD__ 
)

Simple wrapper for request( 'POST' ), parameters have same meaning as for request()

Since
1.34
Parameters
string$url
array$options
string$caller
Returns
string|null

Definition at line 158 of file HttpRequestFactory.php.

References MediaWiki\Http\HttpRequestFactory\request().

◆ request()

MediaWiki\Http\HttpRequestFactory::request (   $method,
  $url,
array  $options = [],
  $caller = __METHOD__ 
)

Perform an HTTP request.

Since
1.34
Parameters
string$methodHTTP method. Usually GET/POST
string$urlFull URL to act on. If protocol-relative, will be expanded to an http:// URL
array$optionsSee HttpRequestFactory::create
string$callerThe method making this request, for profiling
Returns
string|null null on failure or a string on success

Definition at line 110 of file HttpRequestFactory.php.

References MediaWiki\Http\HttpRequestFactory\create().

Referenced by MediaWiki\Http\HttpRequestFactory\get(), and MediaWiki\Http\HttpRequestFactory\post().


The documentation for this class was generated from the following file: