Various HTTP related functions.
More...
|
static | createMultiClient ( $options=[]) |
| Get a configured MultiHttpClient.
|
|
static | get ( $url, $options=[], $caller=__METHOD__) |
| Simple wrapper for Http::request( 'GET' )
|
|
static | getProxy () |
| Gets the relevant proxy from $wgHTTPProxy.
|
|
static | isValidURI ( $uri) |
| Checks that the given URI is a valid one.
|
|
static | post ( $url, $options=[], $caller=__METHOD__) |
| Simple wrapper for Http::request( 'POST' )
|
|
static | request ( $method, $url, $options=[], $caller=__METHOD__) |
| Perform an HTTP request.
|
|
static | userAgent () |
| A standard user-agent we can use for external requests.
|
|
Various HTTP related functions.
Definition at line 27 of file Http.php.
◆ createMultiClient()
static Http::createMultiClient |
( |
| $options = [] | ) |
|
|
static |
◆ get()
static Http::get |
( |
| $url, |
|
|
| $options = [], |
|
|
| $caller = __METHOD__ ) |
|
static |
Simple wrapper for Http::request( 'GET' )
- See also
- Http::request()
- Since
- 1.25 Second parameter $timeout removed. Second parameter is now $options which can be given a 'timeout'
- Parameters
-
string | $url | |
array | $options | |
string | $caller | The method making this request, for profiling |
- Returns
- string|bool false on error
Reimplemented in MediaWikiPageNameNormalizerTestMockHttp.
Definition at line 98 of file Http.php.
References $args, $options, request, and wfWarn().
◆ getProxy()
static Http::getProxy |
( |
| ) |
|
|
static |
Gets the relevant proxy from $wgHTTPProxy.
- Returns
- mixed The proxy address or an empty string if not set.
Definition at line 158 of file Http.php.
References $wgHTTPProxy.
◆ isValidURI()
static Http::isValidURI |
( |
| $uri | ) |
|
|
static |
Checks that the given URI is a valid one.
Hardcoding the protocols, because we only want protocols that both cURL and php support.
file:// should not be allowed here for security purpose (r67684)
- Todo
- FIXME this is wildly inaccurate and fails to actually check most stuff
- Parameters
-
string | $uri | URI to check for validity |
- Returns
- bool
Definition at line 146 of file Http.php.
◆ post()
static Http::post |
( |
| $url, |
|
|
| $options = [], |
|
|
| $caller = __METHOD__ ) |
|
static |
Simple wrapper for Http::request( 'POST' )
- See also
- Http::request()
- Parameters
-
string | $url | |
array | $options | |
string | $caller | The method making this request, for profiling |
- Returns
- string|bool false on error
Definition at line 121 of file Http.php.
References $options, and request.
◆ request()
static Http::request |
( |
| $method, |
|
|
| $url, |
|
|
| $options = [], |
|
|
| $caller = __METHOD__ ) |
|
static |
Perform an HTTP request.
- Parameters
-
string | $method | HTTP method. Usually GET/POST |
string | $url | Full URL to act on. If protocol-relative, will be expanded to an http:// URL |
array | $options | Options to pass to MWHttpRequest object. Possible 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 | $caller | The method making this request, for profiling |
- Returns
- string|bool (bool)false on failure or a string on success
Definition at line 61 of file Http.php.
References $options, and $req.
◆ userAgent()
static Http::userAgent |
( |
| ) |
|
|
static |
A standard user-agent we can use for external requests.
- Returns
- string
Definition at line 129 of file Http.php.
References $wgVersion.
◆ $httpEngine
Http::$httpEngine = false |
|
static |
The documentation for this class was generated from the following file: