MediaWiki
REL1_22
|
This wrapper class will call out to curl (if available) or fallback to regular PHP if necessary for handling internal HTTP requests. More...
Public Member Functions | |
canFollowRedirects () | |
Returns true if the backend can follow redirects. | |
execute () | |
Take care of whatever is necessary to perform the URI request. | |
getContent () | |
Get the body, or content, of the response to the request. | |
getCookieJar () | |
Returns the cookie jar in use. | |
getFinalUrl () | |
Returns the final URL after all redirections. | |
getHeaderList () | |
Get an array of the headers. | |
getResponseHeader ($header) | |
Returns the value of the given response header. | |
getResponseHeaders () | |
Returns an associative array of response headers after the request has been executed. | |
getStatus () | |
Get the integer value of the HTTP status code (e.g. | |
isRedirect () | |
Returns true if the last status code was a redirect. | |
proxySetup () | |
Take care of setting up the proxy (do nothing if "noProxy" is set) | |
read ($fh, $content) | |
A generic callback to read the body of the response from a remote server. | |
setCallback ($callback) | |
Set a read callback to accept data read from the HTTP request. | |
setCookie ($name, $value=null, $attr=null) | |
Sets a cookie. | |
setCookieJar ($jar) | |
Tells the MWHttpRequest object to use this pre-loaded CookieJar. | |
setData ($args) | |
Set the parameters of the request. | |
setHeader ($name, $value) | |
Set an arbitrary header. | |
setReferer ($url) | |
Set the referrer header. | |
setUserAgent ($UA) | |
Set the user agent. | |
Static Public Member Functions | |
static | canMakeRequests () |
Simple function to test if we can make any sort of requests at all, using cURL or fopen() | |
static | factory ($url, $options=null) |
Generate a new request object. | |
Public Attributes | |
$status | |
const | SUPPORTS_FILE_POSTS = false |
Protected Member Functions | |
__construct ($url, $options=array()) | |
parseCookies () | |
Parse the cookies in the response headers and store them in the cookie jar. | |
parseHeader () | |
Parses the headers, including the HTTP status code and any Set-Cookie headers. | |
setStatus () | |
Sets HTTPRequest status member to a fatal value with the error message if the returned integer value of the status code was not successful (< 300) or a redirect (>=300 and < 400). | |
Protected Attributes | |
$caInfo = null | |
$callback | |
$content | |
CookieJar | $cookieJar |
$followRedirects = false | |
$headerList = array() | |
$headersOnly = null | |
$maxRedirects = 5 | |
$method = "GET" | |
$noProxy = false | |
$parsedUrl | |
$postData = null | |
$proxy = null | |
$reqHeaders = array() | |
$respHeaders = array() | |
$respStatus = "200 Ok" | |
$respVersion = "0.9" | |
$sslVerifyCert = true | |
$sslVerifyHost = true | |
$timeout = 'default' | |
$url |
This wrapper class will call out to curl (if available) or fallback to regular PHP if necessary for handling internal HTTP requests.
Renamed from HttpRequest to MWHttpRequest to avoid conflict with PHP's HTTP extension.
Definition at line 186 of file HttpFunctions.php.
MWHttpRequest::__construct | ( | $ | url, |
$ | options = array() |
||
) | [protected] |
string | $url | url to use. If protocol-relative, will be expanded to an http:// URL |
array | $options | (optional) extra params to pass (see Http::request()) |
Definition at line 221 of file HttpFunctions.php.
Returns true if the backend can follow redirects.
Overridden by the child classes.
Reimplemented in CurlHttpRequest.
Definition at line 696 of file HttpFunctions.php.
static MWHttpRequest::canMakeRequests | ( | ) | [static] |
Simple function to test if we can make any sort of requests at all, using cURL or fopen()
Definition at line 271 of file HttpFunctions.php.
Take care of whatever is necessary to perform the URI request.
Reimplemented in PhpHttpRequest, and CurlHttpRequest.
Definition at line 438 of file HttpFunctions.php.
static MWHttpRequest::factory | ( | $ | url, |
$ | options = null |
||
) | [static] |
Generate a new request object.
string | $url | url to use |
array | $options | (optional) extra params to pass (see Http::request()) |
MWException |
Reimplemented in MWHttpRequestTester.
Definition at line 283 of file HttpFunctions.php.
Referenced by ForeignAPIRepo\httpGet(), SpecialUploadStash\outputRemoteScaledThumb(), UploadFromUrl\reallyFetchFile(), Http\request(), and ApiTest\testApiGotCookie().
Get the body, or content, of the response to the request.
Definition at line 310 of file HttpFunctions.php.
Returns the final URL after all redirections.
Relative values of the "Location" header are incorrect as stated in RFC, however they do happen and modern browsers support them. This function loops backwards through all locations in order to build the proper absolute URI - Marooned at wikia-inc.com
Note that the multiple Location: headers are an artifact of CURL -- they shouldn't actually get returned this way. Rewrite this when bug 29232 is taken care of (high-level redirect handling rewrite).
Definition at line 653 of file HttpFunctions.php.
Get an array of the headers.
Definition at line 377 of file HttpFunctions.php.
Referenced by CurlHttpRequest\execute(), and PhpHttpRequest\execute().
MWHttpRequest::getResponseHeader | ( | $ | header | ) |
Returns the value of the given response header.
$header | String |
Definition at line 569 of file HttpFunctions.php.
Referenced by PhpHttpRequest\execute().
Returns an associative array of response headers after the request has been executed.
Because some headers (e.g. Set-Cookie) can appear more than once the, each value of the associative array is an array of the values given.
Definition at line 555 of file HttpFunctions.php.
Get the integer value of the HTTP status code (e.g.
200 for "200 Ok") (see RFC2616, section 10, http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for a list of status codes.)
Definition at line 520 of file HttpFunctions.php.
Returns true if the last status code was a redirect.
Definition at line 533 of file HttpFunctions.php.
Referenced by PhpHttpRequest\execute().
MWHttpRequest::parseCookies | ( | ) | [protected] |
Parse the cookies in the response headers and store them in the cookie jar.
Definition at line 624 of file HttpFunctions.php.
MWHttpRequest::parseHeader | ( | ) | [protected] |
Parses the headers, including the HTTP status code and any Set-Cookie headers.
This function expects the headers to be found in an array in the member variable headerList.
Definition at line 471 of file HttpFunctions.php.
Referenced by CurlHttpRequest\execute(), and PhpHttpRequest\execute().
Take care of setting up the proxy (do nothing if "noProxy" is set)
Definition at line 329 of file HttpFunctions.php.
MWHttpRequest::read | ( | $ | fh, |
$ | content | ||
) |
A generic callback to read the body of the response from a remote server.
$fh | handle |
$content | String |
Definition at line 428 of file HttpFunctions.php.
MWHttpRequest::setCallback | ( | $ | callback | ) |
Set a read callback to accept data read from the HTTP request.
By default, data is appended to an internal buffer which can be retrieved through $req->getContent().
To handle data as it comes in -- especially for large files that would not fit in memory -- you can instead set your own callback, in the form function($resource, $buffer) where the first parameter is the low-level resource being read (implementation specific), and the second parameter is the data buffer.
You MUST return the number of bytes handled in the buffer; if fewer bytes are reported handled than were passed to you, the HTTP fetch will be aborted.
$callback | Callback |
MWException |
Definition at line 413 of file HttpFunctions.php.
MWHttpRequest::setCookie | ( | $ | name, |
$ | value = null , |
||
$ | attr = null |
||
) |
Sets a cookie.
Used before a request to set up any individual cookies. Used internally after a request to parse the Set-Cookie headers.
$name | |
$value | null |
$attr | null |
Definition at line 613 of file HttpFunctions.php.
MWHttpRequest::setCookieJar | ( | $ | jar | ) |
Tells the MWHttpRequest object to use this pre-loaded CookieJar.
$jar | CookieJar |
Definition at line 587 of file HttpFunctions.php.
MWHttpRequest::setData | ( | $ | args | ) |
Set the parameters of the request.
$args | Array |
Definition at line 320 of file HttpFunctions.php.
MWHttpRequest::setHeader | ( | $ | name, |
$ | value | ||
) |
MWHttpRequest::setReferer | ( | $ | url | ) |
Set the referrer header.
Definition at line 351 of file HttpFunctions.php.
MWHttpRequest::setStatus | ( | ) | [protected] |
Sets HTTPRequest status member to a fatal value with the error message if the returned integer value of the status code was not successful (< 300) or a redirect (>=300 and < 400).
(see RFC2616, section 10, http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for a list of status codes.)
Definition at line 502 of file HttpFunctions.php.
Referenced by CurlHttpRequest\execute(), and PhpHttpRequest\execute().
MWHttpRequest::setUserAgent | ( | $ | UA | ) |
MWHttpRequest::$caInfo = null [protected] |
Definition at line 197 of file HttpFunctions.php.
MWHttpRequest::$callback [protected] |
Definition at line 202 of file HttpFunctions.php.
MWHttpRequest::$content [protected] |
Definition at line 189 of file HttpFunctions.php.
CookieJar MWHttpRequest::$cookieJar [protected] |
Definition at line 208 of file HttpFunctions.php.
MWHttpRequest::$followRedirects = false [protected] |
Definition at line 204 of file HttpFunctions.php.
MWHttpRequest::$headerList = array() [protected] |
Definition at line 210 of file HttpFunctions.php.
MWHttpRequest::$headersOnly = null [protected] |
Definition at line 191 of file HttpFunctions.php.
MWHttpRequest::$maxRedirects = 5 [protected] |
Definition at line 203 of file HttpFunctions.php.
MWHttpRequest::$method = "GET" [protected] |
Definition at line 198 of file HttpFunctions.php.
MWHttpRequest::$noProxy = false [protected] |
Definition at line 194 of file HttpFunctions.php.
MWHttpRequest::$parsedUrl [protected] |
Definition at line 201 of file HttpFunctions.php.
MWHttpRequest::$postData = null [protected] |
Definition at line 192 of file HttpFunctions.php.
MWHttpRequest::$proxy = null [protected] |
Definition at line 193 of file HttpFunctions.php.
MWHttpRequest::$reqHeaders = array() [protected] |
Definition at line 199 of file HttpFunctions.php.
MWHttpRequest::$respHeaders = array() [protected] |
Definition at line 213 of file HttpFunctions.php.
MWHttpRequest::$respStatus = "200 Ok" [protected] |
Definition at line 212 of file HttpFunctions.php.
MWHttpRequest::$respVersion = "0.9" [protected] |
Definition at line 211 of file HttpFunctions.php.
MWHttpRequest::$sslVerifyCert = true [protected] |
Definition at line 196 of file HttpFunctions.php.
MWHttpRequest::$sslVerifyHost = true [protected] |
Definition at line 195 of file HttpFunctions.php.
MWHttpRequest::$status |
Definition at line 215 of file HttpFunctions.php.
MWHttpRequest::$timeout = 'default' [protected] |
Definition at line 190 of file HttpFunctions.php.
MWHttpRequest::$url [protected] |
Definition at line 200 of file HttpFunctions.php.
Referenced by PhpHttpRequest\execute(), and MWHttpRequestTester\factory().
Reimplemented in CurlHttpRequest.
Definition at line 187 of file HttpFunctions.php.