MediaWiki master
|
Shared code between RequestData and RequestFromGlobals. More...
Inherits MediaWiki\Rest\RequestInterface.
Inherited by MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.
Public Member Functions | |
__clone () | |
__construct ( $cookiePrefix) | |
getBodyType () | |
Returns the MIME type of the request body, according to the content-type header. | |
getCookie ( $name, $default=null) | |
Add the cookie prefix to a specified cookie name and get the value of the resulting prefixed cookie. | |
getCookiePrefix () | |
Get the current cookie prefix. | |
getHeader ( $name) | |
Retrieves a message header value by the given case-insensitive name. | |
getHeaderLine ( $name) | |
Retrieves a comma-separated string of the values for a single header. | |
getHeaders () | |
Retrieves all message header values. | |
getParsedBody () | |
Returns the parsed body as an associative array. | |
getPathParam ( $name) | |
Retrieve a single path parameter. | |
getPathParams () | |
Get the parameters derived from the path template match. | |
hasBody () | |
Return true if the client provided a content-length header or a transfer-encoding header. | |
hasHeader ( $name) | |
Checks if a header exists by the given case-insensitive name. | |
setHeaders ( $headers) | |
Erase any existing headers and replace them with the specified header lines. | |
setParsedBody (?array $data) | |
Specify the data that subsequent calls to getParsedBody() should return. | |
setPathParams ( $params) | |
Erase all path parameters from the object and set the parameter array to the one specified. | |
![]() | |
getBody () | |
Gets the body of the message. | |
getCookieParams () | |
Retrieve cookies. | |
getMethod () | |
Retrieves the HTTP method of the request. | |
getPostParams () | |
Retrieve POST form parameters. | |
getProtocolVersion () | |
Retrieves the HTTP protocol version as a string. | |
getQueryParams () | |
Retrieve query string arguments. | |
getServerParams () | |
Retrieve server parameters. | |
getUploadedFiles () | |
Retrieve normalized file upload data. | |
getUri () | |
Retrieves the URI instance. | |
Protected Member Functions | |
initHeaders () | |
Override this in the implementation class if lazy initialisation of header values is desired. | |
Protected Attributes | |
array | $parsedBody = null |
Additional Inherited Members | |
![]() | |
const | FORM_URLENCODED_CONTENT_TYPE = 'application/x-www-form-urlencoded' |
const | JSON_CONTENT_TYPE = 'application/json' |
const | MULTIPART_FORM_DATA_CONTENT_TYPE = 'multipart/form-data' |
Shared code between RequestData and RequestFromGlobals.
Definition at line 8 of file RequestBase.php.
MediaWiki\Rest\RequestBase::__construct | ( | $cookiePrefix | ) |
string | $cookiePrefix |
Reimplemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.
Definition at line 26 of file RequestBase.php.
MediaWiki\Rest\RequestBase::__clone | ( | ) |
Definition at line 39 of file RequestBase.php.
MediaWiki\Rest\RequestBase::getBodyType | ( | ) |
Returns the MIME type of the request body, according to the content-type header.
The value returned by this method must be a lower-case string with no whitespace and no additional information beyond the mime type. In particular, any "parameters" must be stripped from the value of the content-type header. See RFC 9110 section 8.3.1.
Implements MediaWiki\Rest\RequestInterface.
Definition at line 122 of file RequestBase.php.
MediaWiki\Rest\RequestBase::getCookie | ( | $name, | |
$default = null ) |
Add the cookie prefix to a specified cookie name and get the value of the resulting prefixed cookie.
If the cookie does not exist, $default is returned.
string | $name | |
mixed | null | $default |
Implements MediaWiki\Rest\RequestInterface.
Definition at line 104 of file RequestBase.php.
References MediaWiki\Rest\RequestInterface\getCookieParams(), and MediaWiki\Rest\RequestBase\getCookiePrefix().
MediaWiki\Rest\RequestBase::getCookiePrefix | ( | ) |
Get the current cookie prefix.
Implements MediaWiki\Rest\RequestInterface.
Definition at line 100 of file RequestBase.php.
Referenced by MediaWiki\Rest\RequestBase\getCookie().
MediaWiki\Rest\RequestBase::getHeader | ( | $name | ) |
Retrieves a message header value by the given case-insensitive name.
This method returns an array of all the header values of the given case-insensitive header name.
If the header does not appear in the message, this method MUST return an empty array.
A single header value may be a string containing a comma-separated list. Lists will not necessarily be split into arrays. See the comment on HeaderContainer::convertToListAndString().
string | $name | Case-insensitive header field name. |
Implements MediaWiki\Rest\RequestInterface.
Definition at line 67 of file RequestBase.php.
References MediaWiki\Rest\RequestBase\initHeaders().
MediaWiki\Rest\RequestBase::getHeaderLine | ( | $name | ) |
Retrieves a comma-separated string of the values for a single header.
This method returns all of the header values of the given case-insensitive header name as a string concatenated together using a comma.
NOTE: Not all header values may be appropriately represented using comma concatenation. For such headers, use getHeader() instead and supply your own delimiter when concatenating.
If the header does not appear in the message, this method MUST return an empty string.
string | $name | Case-insensitive header field name. |
Implements MediaWiki\Rest\RequestInterface.
Definition at line 81 of file RequestBase.php.
References MediaWiki\Rest\RequestBase\initHeaders().
MediaWiki\Rest\RequestBase::getHeaders | ( | ) |
Retrieves all message header values.
The keys represent the header name as it will be sent over the wire, and each value is an array of strings associated with the header.
// Represent the headers as a string foreach ($message->getHeaders() as $name => $values) { echo $name . ": " . implode(", ", $values); } // Emit headers iteratively: foreach ($message->getHeaders() as $name => $values) { foreach ($values as $value) { header(sprintf('%s: %s', $name, $value), false); } }
While header names are not case-sensitive, getHeaders() will preserve the exact case in which headers were originally specified.
A single header value may be a string containing a comma-separated list. Lists will not necessarily be split into arrays. See the comment on HeaderContainer::convertToListAndString().
Implements MediaWiki\Rest\RequestInterface.
Definition at line 60 of file RequestBase.php.
References MediaWiki\Rest\RequestBase\initHeaders().
MediaWiki\Rest\RequestBase::getParsedBody | ( | ) |
Returns the parsed body as an associative array.
If setParsedBody() was called on a given RequestInterface object, this method must return the data passed to that call.
If setParsedBody() was not called, implementations may return body data they get from the runtime environment, or null.
Implements MediaWiki\Rest\RequestInterface.
Definition at line 114 of file RequestBase.php.
MediaWiki\Rest\RequestBase::getPathParam | ( | $name | ) |
Retrieve a single path parameter.
Retrieves a single path parameter as described in getPathParams(). If the attribute has not been previously set, returns null.
string | $name | The parameter name. |
Implements MediaWiki\Rest\RequestInterface.
Definition at line 96 of file RequestBase.php.
MediaWiki\Rest\RequestBase::getPathParams | ( | ) |
Get the parameters derived from the path template match.
Implements MediaWiki\Rest\RequestInterface.
Definition at line 92 of file RequestBase.php.
MediaWiki\Rest\RequestBase::hasBody | ( | ) |
Return true if the client provided a content-length header or a transfer-encoding header.
Implements MediaWiki\Rest\RequestInterface.
Reimplemented in MediaWiki\Rest\RequestData.
Definition at line 140 of file RequestBase.php.
MediaWiki\Rest\RequestBase::hasHeader | ( | $name | ) |
Checks if a header exists by the given case-insensitive name.
string | $name | Case-insensitive header field name. |
Implements MediaWiki\Rest\RequestInterface.
Definition at line 74 of file RequestBase.php.
References MediaWiki\Rest\RequestBase\initHeaders().
|
protected |
Override this in the implementation class if lazy initialisation of header values is desired.
It should call setHeaders().
Reimplemented in MediaWiki\Rest\RequestFromGlobals.
Definition at line 36 of file RequestBase.php.
Referenced by MediaWiki\Rest\RequestBase\getHeader(), MediaWiki\Rest\RequestBase\getHeaderLine(), MediaWiki\Rest\RequestBase\getHeaders(), and MediaWiki\Rest\RequestBase\hasHeader().
MediaWiki\Rest\RequestBase::setHeaders | ( | $headers | ) |
Erase any existing headers and replace them with the specified header lines.
Call this either from the constructor or from initHeaders() of the implementing class.
string[] | $headers | The header lines |
Definition at line 55 of file RequestBase.php.
References MediaWiki\Rest\HeaderContainer\resetHeaders().
Referenced by MediaWiki\Rest\RequestData\__construct(), and MediaWiki\Rest\RequestFromGlobals\initHeaders().
MediaWiki\Rest\RequestBase::setParsedBody | ( | ?array | $data | ) |
Specify the data that subsequent calls to getParsedBody() should return.
This is intended for use by the framework to make a parsed representation of the body data known to request handlers.
array | null | $data | The body data. |
Implements MediaWiki\Rest\RequestInterface.
Definition at line 118 of file RequestBase.php.
Referenced by MediaWiki\Rest\RequestData\__construct().
MediaWiki\Rest\RequestBase::setPathParams | ( | $params | ) |
Erase all path parameters from the object and set the parameter array to the one specified.
string[] | $params |
Implements MediaWiki\Rest\RequestInterface.
Definition at line 88 of file RequestBase.php.
Referenced by MediaWiki\Rest\RequestData\__construct().
|
protected |
Definition at line 20 of file RequestBase.php.