MediaWiki master
|
A request interface similar to PSR-7's ServerRequestInterface. More...
Inherited by MediaWiki\Rest\RequestBase.
Public Member Functions | |
getBody () | |
Gets the body of the message. | |
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. | |
getCookieParams () | |
Retrieve cookies. | |
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. | |
getMethod () | |
Retrieves the HTTP method of the request. | |
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. | |
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. | |
hasBody () | |
Determines whether the request has body data associated with it. | |
hasHeader ( $name) | |
Checks if a header exists by the given case-insensitive name. | |
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. | |
Public Attributes | |
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' |
A request interface similar to PSR-7's ServerRequestInterface.
Definition at line 39 of file RequestInterface.php.
MediaWiki\Rest\RequestInterface::getBody | ( | ) |
Gets the body of the message.
Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.
Referenced by MediaWiki\Rest\Validator\JsonBodyValidator\validateBody(), and MediaWiki\Rest\Validator\Validator\validateBody().
MediaWiki\Rest\RequestInterface::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.
Implemented in MediaWiki\Rest\RequestBase.
MediaWiki\Rest\RequestInterface::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 |
Implemented in MediaWiki\Rest\RequestBase.
MediaWiki\Rest\RequestInterface::getCookieParams | ( | ) |
Retrieve cookies.
Retrieves cookies sent by the client to the server.
The data MUST be compatible with the structure of the $_COOKIE superglobal.
Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.
Referenced by MediaWiki\Rest\RequestBase\getCookie().
MediaWiki\Rest\RequestInterface::getCookiePrefix | ( | ) |
MediaWiki\Rest\RequestInterface::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. |
Implemented in MediaWiki\Rest\RequestBase.
Referenced by MediaWiki\Rest\CorsUtils\authorize(), and MediaWiki\Rest\ConditionalHeaderUtil\checkPreconditions().
MediaWiki\Rest\RequestInterface::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. |
Implemented in MediaWiki\Rest\RequestBase.
Referenced by MediaWiki\Rest\Handler\PageHTMLHandler\postValidationSetup(), and MediaWiki\Rest\Validator\Validator\validateBody().
MediaWiki\Rest\RequestInterface::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().
Implemented in MediaWiki\Rest\RequestBase.
MediaWiki\Rest\RequestInterface::getMethod | ( | ) |
Retrieves the HTTP method of the request.
Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.
Referenced by MediaWiki\Rest\ConditionalHeaderUtil\checkPreconditions(), and MediaWiki\Rest\Validator\Validator\validateBody().
MediaWiki\Rest\RequestInterface::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.
Implemented in MediaWiki\Rest\RequestBase.
Referenced by MediaWiki\Rest\Handler\initForExecute().
MediaWiki\Rest\RequestInterface::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. |
Implemented in MediaWiki\Rest\RequestBase.
MediaWiki\Rest\RequestInterface::getPathParams | ( | ) |
Get the parameters derived from the path template match.
Implemented in MediaWiki\Rest\RequestBase.
MediaWiki\Rest\RequestInterface::getPostParams | ( | ) |
Retrieve POST form parameters.
This will return an array of parameters in the format of $_POST.
Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.
MediaWiki\Rest\RequestInterface::getProtocolVersion | ( | ) |
Retrieves the HTTP protocol version as a string.
The string MUST contain only the HTTP version number (e.g., "1.1", "1.0").
Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.
MediaWiki\Rest\RequestInterface::getQueryParams | ( | ) |
Retrieve query string arguments.
Retrieves the deserialized query string arguments, if any.
Note: the query params might not be in sync with the URI or server params. If you need to ensure you are only getting the original values, you may need to parse the query string from getUri()->getQuery()
or from the QUERY_STRING
server param.
Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.
MediaWiki\Rest\RequestInterface::getServerParams | ( | ) |
Retrieve server parameters.
Retrieves data related to the incoming request environment, typically derived from PHP's $_SERVER superglobal. The data IS NOT REQUIRED to originate from $_SERVER.
Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.
MediaWiki\Rest\RequestInterface::getUploadedFiles | ( | ) |
Retrieve normalized file upload data.
This method returns upload metadata in a normalized tree, with each leaf an instance of Psr\Http\Message\UploadedFileInterface.
Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.
MediaWiki\Rest\RequestInterface::getUri | ( | ) |
Retrieves the URI instance.
This method MUST return a UriInterface instance.
UriInterface Returns a UriInterface instance representing the URI of the request.
Implemented in MediaWiki\Rest\RequestData, and MediaWiki\Rest\RequestFromGlobals.
MediaWiki\Rest\RequestInterface::hasBody | ( | ) |
Determines whether the request has body data associated with it.
Note that this method may return true even if the body is empty.
Implemented in MediaWiki\Rest\RequestBase, and MediaWiki\Rest\RequestData.
MediaWiki\Rest\RequestInterface::hasHeader | ( | $name | ) |
Checks if a header exists by the given case-insensitive name.
string | $name | Case-insensitive header field name. |
Implemented in MediaWiki\Rest\RequestBase.
Referenced by MediaWiki\Rest\CorsUtils\authorize(), and MediaWiki\Rest\ConditionalHeaderUtil\checkPreconditions().
MediaWiki\Rest\RequestInterface::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. |
Implemented in MediaWiki\Rest\RequestBase.
MediaWiki\Rest\RequestInterface::setPathParams | ( | $params | ) |
Erase all path parameters from the object and set the parameter array to the one specified.
string[] | $params |
Implemented in MediaWiki\Rest\RequestBase.
const MediaWiki\Rest\RequestInterface::FORM_URLENCODED_CONTENT_TYPE = 'application/x-www-form-urlencoded' |
Definition at line 52 of file RequestInterface.php.
const MediaWiki\Rest\RequestInterface::JSON_CONTENT_TYPE = 'application/json' |
Definition at line 50 of file RequestInterface.php.
const MediaWiki\Rest\RequestInterface::MULTIPART_FORM_DATA_CONTENT_TYPE = 'multipart/form-data' |
Definition at line 51 of file RequestInterface.php.