MediaWiki fundraising/REL1_35
Http Class Reference

Various HTTP related functions. More...

Static Public Member Functions

static createMultiClient (array $options=[])
 Get a configured MultiHttpClient.
 
static get ( $url, array $options=[], $caller=__METHOD__)
 Simple wrapper for Http::request( 'GET' )
 
static getProxy ()
 Gets the relevant proxy from $wgHTTPProxy.
 
static isValidURI ( $uri)
 Check that the given URI is a valid one.
 
static post ( $url, array $options=[], $caller=__METHOD__)
 Simple wrapper for Http::request( 'POST' )
 
static request ( $method, $url, array $options=[], $caller=__METHOD__)
 Perform an HTTP request.
 
static userAgent ()
 A standard user-agent we can use for external requests.
 

Static Public Attributes

static $httpEngine = null
 

Detailed Description

Various HTTP related functions.

Deprecated
since 1.34

Definition at line 28 of file Http.php.

Member Function Documentation

◆ createMultiClient()

static Http::createMultiClient ( array $options = [])
static

Get a configured MultiHttpClient.

Deprecated
since 1.34, use MediaWikiServices::getHttpRequestFactory()->createMultiClient()
Parameters
array$options
Returns
MultiHttpClient

Definition at line 141 of file Http.php.

References $wgHTTPProxy, and wfDeprecated().

◆ get()

static Http::get ( $url,
array $options = [],
$caller = __METHOD__ )
static

Simple wrapper for Http::request( 'GET' )

Deprecated
since 1.34, use HttpRequestFactory::get()
Since
1.25 Second parameter $timeout removed. Second parameter is now $options which can be given a 'timeout'
Parameters
string$url
array$options
string$callerThe method making this request, for profiling
Returns
string|bool false on error

Definition at line 63 of file Http.php.

References $args, request(), and wfWarn().

Referenced by ImportImages\getFileCommentFromSourceWiki(), and ImportImages\getFileUserFromSourceWiki().

◆ getProxy()

static Http::getProxy ( )
static

Gets the relevant proxy from $wgHTTPProxy.

Deprecated
since 1.34, use $wgHTTPProxy directly
Returns
string The proxy address or an empty string if not set.

Definition at line 127 of file Http.php.

References $wgHTTPProxy, and wfDeprecated().

◆ isValidURI()

static Http::isValidURI ( $uri)
static

Check that the given URI is a valid one.

This hardcodes a small set of protocols only, because we want to deterministically reject protocols not supported by all HTTP-transport methods.

"file://" specifically must not be allowed, for security purpose (see https://www.mediawiki.org/wiki/Special:Code/MediaWiki/r67684).

Todo
FIXME this is wildly inaccurate and fails to actually check most stuff
Deprecated
since 1.34, use MWHttpRequest::isValidURI
Parameters
string$uriURI to check for validity
Returns
bool

Definition at line 117 of file Http.php.

Referenced by PhpHttpRequest\execute(), and UploadFromUrl\fetchFile().

◆ post()

static Http::post ( $url,
array $options = [],
$caller = __METHOD__ )
static

Simple wrapper for Http::request( 'POST' )

Deprecated
since 1.34, use HttpRequestFactory::post()
Parameters
string$url
array$options
string$callerThe method making this request, for profiling
Returns
string|bool false on error

Definition at line 87 of file Http.php.

References request().

◆ request()

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

Perform an HTTP request.

Deprecated
since 1.34, use HttpRequestFactory::request()
Parameters
string$methodHTTP method. Usually GET/POST
string$urlFull URL to act on. If protocol-relative, will be expanded to an http:// URL
array$optionsOptions to pass to MWHttpRequest object. See HttpRequestFactory::create docs
string$callerThe method making this request, for profiling
Returns
string|bool (bool)false on failure or a string on success

Definition at line 44 of file Http.php.

Referenced by get(), and post().

◆ userAgent()

static Http::userAgent ( )
static

A standard user-agent we can use for external requests.

Deprecated
since 1.34, use HttpRequestFactory::getUserAgent()
Returns
string

Definition at line 97 of file Http.php.

Referenced by MediaWiki\Sparql\SparqlClient\__construct(), ForeignAPIRepo\getUserAgent(), and SquidPurgeClient\queuePurge().

Member Data Documentation

◆ $httpEngine

Http::$httpEngine = null
static
Deprecated
since 1.34, just use the default engine

Definition at line 30 of file Http.php.

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


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