MediaWiki  1.23.8
Http Class Reference

Various HTTP related functions. More...

Static Public Member Functions

static get ( $url, $timeout='default', $options=array())
 Simple wrapper for Http::request( 'GET' ) More...
static isLocalURL ( $url)
 Check if the URL can be served by localhost. More...
static isValidURI ( $uri)
 Checks that the given URI is a valid one. More...
static post ( $url, $options=array())
 Simple wrapper for Http::request( 'POST' ) More...
static request ( $method, $url, $options=array())
 Perform an HTTP request. More...
static userAgent ()
 A standard user-agent we can use for external requests. More...

Static Public Attributes

static $httpEngine = false

Detailed Description

Various HTTP related functions.

Definition at line 32 of file HttpFunctions.php.

Member Function Documentation

◆ get()

◆ isLocalURL()

static Http::isLocalURL (   $url)

Check if the URL can be served by localhost.

string$urlfull url to check

Definition at line 116 of file HttpFunctions.php.

References $matches, $wgCommandLineMode, array(), and global.

Referenced by MWHttpRequest\proxySetup().

◆ isValidURI()

static Http::isValidURI (   $uri)

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)

FIXME this is wildly inaccurate and fails to actually check most stuff
$uriMixed: URI to check for validity

Definition at line 172 of file HttpFunctions.php.

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

◆ post()

static Http::post (   $url,
  $options = array() 

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

See also

Definition at line 106 of file HttpFunctions.php.

References $options, and request().

◆ request()

static Http::request (   $method,
  $options = array() 

Perform an HTTP request.

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. 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
Mixed: (bool)false on failure or a string on success

Definition at line 60 of file HttpFunctions.php.

References $options, MWHttpRequest\factory(), wfDebug(), wfProfileIn(), and wfProfileOut().

Referenced by FileBackendTest\doTestGetFileHttpUrl(), get(), ImportStreamSource\newFromURL(), and post().

◆ userAgent()

static Http::userAgent ( )

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


Definition at line 155 of file HttpFunctions.php.

References global.

Referenced by MWHttpRequest\execute(), ForeignAPIRepo\getUserAgent(), and SquidPurgeClient\queuePurge().

Member Data Documentation

◆ $httpEngine

Http::$httpEngine = false

Definition at line 33 of file HttpFunctions.php.

Referenced by MWHttpRequestTester\factory(), and MWHttpRequest\factory().

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