MediaWiki master
|
MWHttpRequest implemented using the Guzzle library. More...
Inherits MWHttpRequest.
Public Member Functions | |
__construct ( $url, array $options=[], $caller=__METHOD__, ?Profiler $profiler=null) | |
execute () | |
setCallback ( $callback) | |
Set a read callback to accept data read from the HTTP request. | |
Public Member Functions inherited from MWHttpRequest | |
addTelemetry (TelemetryHeadersInterface $telemetry) | |
Add Telemetry information to the request. | |
canFollowRedirects () | |
Returns true if the backend can follow redirects. | |
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. | |
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. | |
read ( $fh, $content) | |
A generic callback to read the body of the response from a remote server. | |
setCookie ( $name, $value, array $attr=[]) | |
Sets a cookie. | |
setCookieJar (CookieJar $jar) | |
Tells the MWHttpRequest object to use this pre-loaded CookieJar. | |
setData (array $args) | |
Set the parameters of the request. | |
setHeader ( $name, $value) | |
Set an arbitrary header. | |
setLogger (LoggerInterface $logger) | |
setOriginalRequest ( $originalRequest) | |
Set information about the original request. | |
setUserAgent ( $UA) | |
Public Attributes | |
const | SUPPORTS_FILE_POSTS = true |
Public Attributes inherited from MWHttpRequest | |
const | SUPPORTS_FILE_POSTS = false |
Protected Member Functions | |
doSetCallback ( $callback) | |
Worker function for setting callbacks. | |
parseHeader () | |
Guzzle provides headers as an array. | |
prepare () | |
usingCurl () | |
Protected Member Functions inherited from MWHttpRequest | |
getHeaderList () | |
Get an array of the headers. | |
parseCookies () | |
Parse the cookies in the response headers and store them in the cookie jar. | |
proxySetup () | |
Take care of setting up the proxy (do nothing if "noProxy" is set) | |
setReverseProxy (string $proxy) | |
Enable use of a reverse proxy in which the hostname is passed as a "Host" header, and the request is sent to the proxy's host:port instead. | |
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 (1-299) or a redirect (300-399). | |
Protected Attributes | |
array | $guzzleOptions = [ 'http_errors' => false ] |
callable null | $handler = null |
StreamInterface null | $sink = null |
Protected Attributes inherited from MWHttpRequest | |
string null | $caInfo = null |
callable | $callback |
int | $connectTimeout |
string null | $content |
CookieJar | $cookieJar |
bool | $followRedirects = false |
array | $headerList = [] |
bool null | $headersOnly = null |
LoggerInterface | $logger |
int | $maxRedirects = 5 |
string | $method = "GET" |
bool | $noProxy = false |
array false | $parsedUrl |
array null | $postData = null |
string | $profileName |
Profiler | $profiler |
string null | $proxy = null |
array | $reqHeaders = [] |
string[][] | $respHeaders = [] |
string | $respStatus = "200 Ok" |
string | $respVersion = "0.9" |
bool | $sslVerifyCert = true |
bool | $sslVerifyHost = true |
StatusValue | $status |
int string | $timeout = 'default' |
string | $url |
Additional Inherited Members | |
Static Public Member Functions inherited from MWHttpRequest | |
static | canMakeRequests () |
Simple function to test if we can make any sort of requests at all, using cURL or fopen() | |
static | isValidURI ( $uri) |
Check that the given URI is a valid one. | |
MWHttpRequest implemented using the Guzzle library.
Definition at line 46 of file GuzzleHttpRequest.php.
GuzzleHttpRequest::__construct | ( | $url, | |
array | $options = [], | ||
$caller = __METHOD__, | |||
?Profiler | $profiler = null ) |
string | $url | Url to use. If protocol-relative, will be expanded to an http:// URL |
array | $options | (optional) extra params to pass (see HttpRequestFactory::create()) |
string | $caller | The method making this request, for profiling |
Profiler | null | $profiler | An instance of the profiler for profiling, or null |
Exception |
Reimplemented from MWHttpRequest.
Definition at line 65 of file GuzzleHttpRequest.php.
References MWHttpRequest\$profiler, and $url.
|
protected |
Worker function for setting callbacks.
Calls can originate both internally and externally via setCallback). Defaults to the internal read callback if $callback is null.
If a sink is already specified, this does nothing. This causes the 'sink' constructor option to override the 'callback' constructor option.
callable | null | $callback |
Reimplemented from MWHttpRequest.
Definition at line 111 of file GuzzleHttpRequest.php.
References MWHttpRequest\$callback.
Referenced by prepare(), and setCallback().
GuzzleHttpRequest::execute | ( | ) |
Reimplemented from MWHttpRequest.
Definition at line 123 of file GuzzleHttpRequest.php.
References MWHttpRequest\$postData, MWHttpRequest\getCookieJar(), parseHeader(), prepare(), MWHttpRequest\setStatus(), and usingCurl().
|
protected |
Guzzle provides headers as an array.
Reprocess to match our expectations. Guzzle will have already parsed and removed the status line (in EasyHandle::createResponse).
Reimplemented from MWHttpRequest.
Definition at line 285 of file GuzzleHttpRequest.php.
Referenced by execute().
|
protected |
Reimplemented from MWHttpRequest.
Definition at line 271 of file GuzzleHttpRequest.php.
References doSetCallback().
Referenced by execute().
GuzzleHttpRequest::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.
This function overrides any 'sink' or 'callback' constructor option.
callable | null | $callback |
Reimplemented from MWHttpRequest.
Definition at line 97 of file GuzzleHttpRequest.php.
References MWHttpRequest\$callback, and doSetCallback().
|
protected |
Definition at line 276 of file GuzzleHttpRequest.php.
Referenced by execute().
|
protected |
Definition at line 54 of file GuzzleHttpRequest.php.
|
protected |
Definition at line 50 of file GuzzleHttpRequest.php.
|
protected |
Definition at line 52 of file GuzzleHttpRequest.php.
const GuzzleHttpRequest::SUPPORTS_FILE_POSTS = true |
Definition at line 47 of file GuzzleHttpRequest.php.