MediaWiki master
RequestInterface.php
Go to the documentation of this file.
1<?php
2
31namespace MediaWiki\Rest;
32
33use Psr\Http\Message\StreamInterface;
34use Psr\Http\Message\UriInterface;
35
41 public const NO_BODY_METHODS = [ 'GET', 'HEAD' ];
42
44 public const BODY_METHODS = [ 'POST', 'PUT' ];
45
46 // NOTE: per RFC 7231 (https://www.rfc-editor.org/rfc/rfc7231#section-4.3.5), sending a body
47 // with the DELETE method "has no defined semantics". We allow it, as it is useful for
48 // passing the csrf token required by some authentication methods.
49
50 public const JSON_CONTENT_TYPE = 'application/json';
51 public const MULTIPART_FORM_DATA_CONTENT_TYPE = 'multipart/form-data';
52 public const FORM_URLENCODED_CONTENT_TYPE = 'application/x-www-form-urlencoded';
53
55 public const FORM_DATA_CONTENT_TYPES = [
58 ];
59
65 public function getMethod();
66
76 public function getUri();
77
78 // MessageInterface
79
87 public function getProtocolVersion();
88
118 public function getHeaders();
119
138 public function getHeader( $name );
139
148 public function hasHeader( $name );
149
169 public function getHeaderLine( $name );
170
176 public function getBody();
177
178 // ServerRequestInterface
179
189 public function getServerParams();
190
201 public function getCookieParams();
202
215 public function getQueryParams();
216
226 public function getUploadedFiles();
227
228 // MediaWiki extensions to PSR-7
229
235 public function getPathParams();
236
247 public function getPathParam( $name );
248
255 public function setPathParams( $params );
256
262 public function getCookiePrefix();
263
273 public function getCookie( $name, $default = null );
274
282 public function getPostParams();
283
297 public function getParsedBody(): ?array;
298
309 public function setParsedBody( ?array $data );
310
323 public function getBodyType(): ?string;
324
333 public function hasBody(): bool;
334}
array $params
The job parameters.
A request interface similar to PSR-7's ServerRequestInterface.
getCookiePrefix()
Get the current cookie prefix.
getPathParams()
Get the parameters derived from the path template match.
getUploadedFiles()
Retrieve normalized file upload data.
getQueryParams()
Retrieve query string arguments.
getBodyType()
Returns the MIME type of the request body, according to the content-type header.
getMethod()
Retrieves the HTTP method of the request.
getBody()
Gets the body of the message.
getUri()
Retrieves the URI instance.
getCookie( $name, $default=null)
Add the cookie prefix to a specified cookie name and get the value of the resulting prefixed cookie.
getHeaders()
Retrieves all message header values.
getServerParams()
Retrieve server parameters.
hasBody()
Determines whether the request has body data associated with it.
getHeaderLine( $name)
Retrieves a comma-separated string of the values for a single header.
setPathParams( $params)
Erase all path parameters from the object and set the parameter array to the one specified.
setParsedBody(?array $data)
Specify the data that subsequent calls to getParsedBody() should return.
getPostParams()
Retrieve POST form parameters.
getPathParam( $name)
Retrieve a single path parameter.
getCookieParams()
Retrieve cookies.
getParsedBody()
Returns the parsed body as an associative array.
hasHeader( $name)
Checks if a header exists by the given case-insensitive name.
getHeader( $name)
Retrieves a message header value by the given case-insensitive name.
getProtocolVersion()
Retrieves the HTTP protocol version as a string.