MediaWiki  master
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() More...
 
 create ( $url, array $options=[], $caller=__METHOD__)
 Generate a new MWHttpRequest object. More...
 
 get ( $url, array $options=[], $caller=__METHOD__)
 Simple wrapper for request( 'GET' ), parameters have same meaning as for request() More...
 
 getUserAgent ()
 
 post ( $url, array $options=[], $caller=__METHOD__)
 Simple wrapper for request( 'POST' ), parameters have same meaning as for request() More...
 
 request ( $method, $url, array $options=[], $caller=__METHOD__)
 Perform an HTTP request. More...
 

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 92 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
  • connectTimeout Timeout for connection, in seconds (curl only)
  • 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').
string$callerThe method making this request, for profiling
Exceptions
RuntimeException
Returns
MWHttpRequest
See also
MWHttpRequest::__construct

Definition at line 66 of file HttpRequestFactory.php.

References Http\$httpEngine, $options, MediaWiki\Logger\LoggerFactory\getInstance(), and Profiler\instance().

Referenced by MediaWiki\Http\HttpRequestFactory\request(), and MWHttpRequestTestCase\setUp().

◆ 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 142 of file HttpRequestFactory.php.

References MediaWiki\Http\HttpRequestFactory\request().

◆ getUserAgent()

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

Definition at line 162 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 155 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 107 of file HttpRequestFactory.php.

References $options, $req, MediaWiki\Http\HttpRequestFactory\create(), MediaWiki\Logger\LoggerFactory\getInstance(), null, and Status\wrap().

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


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