MediaWiki  master
Http Class Reference

Various HTTP related functions. More...

Inheritance diagram for Http:

Static Public Member Functions

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

Static Public Attributes

static $httpEngine = null
 

Detailed Description

Various HTTP related functions.

Deprecated:
since 1.34

Definition at line 29 of file Http.php.

Member Function Documentation

◆ createMultiClient()

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

Get a configured MultiHttpClient.

Deprecated:
since 1.34, construct it directly
Parameters
array$options
Returns
MultiHttpClient

Definition at line 142 of file Http.php.

References $wgHTTPConnectTimeout, $wgHTTPProxy, $wgHTTPTimeout, 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 64 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 128 of file Http.php.

References $wgHTTPProxy, and wfDeprecated().

Referenced by HttpTest\testGetProxy().

◆ 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 118 of file Http.php.

References MWHttpRequest\isValidURI().

Referenced by MWHttpRequest\__construct(), PhpHttpRequest\execute(), UploadFromUrl\fetchFile(), SideBarTest\initMessagesHref(), and HttpUnitTest\testIsValidUri().

◆ 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 88 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 45 of file Http.php.

References $options, and $ret.

◆ 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 98 of file Http.php.

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

Member Data Documentation

◆ $httpEngine

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

Definition at line 31 of file Http.php.

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


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