TYPO3
7.6
|
Public Member Functions | |
__construct ($uri=null, $method=null, $body= 'php://input', array $headers=array()) | |
getHeaders () | |
getHeader ($header) | |
getRequestTarget () | |
withRequestTarget ($requestTarget) | |
getMethod () | |
withMethod ($method) | |
getUri () | |
withUri (UriInterface $uri, $preserveHost=false) | |
Protected Member Functions | |
getHostFromUri () | |
validateMethod ($method) | |
Protected Attributes | |
$requestTarget | |
$method | |
$supportedMethods | |
$uri | |
Default implementation for the RequestInterface of the PSR-7 standard It is the base for any request sent BY PHP.
Please see ServerRequest for the typical use cases in the framework.
Highly inspired by https://github.com/phly/http/
Definition at line 31 of file core/Classes/Http/Request.php.
__construct | ( | $uri = null , |
|
$method = null , |
|||
$body = 'php://input' , |
|||
array | $headers = array() |
||
) |
Constructor, the only place to set all parameters of this Request
NULL | string | $uri | URI for the request, if any. |
NULL | string | $method | HTTP method for the request, if any. |
string | resource | StreamInterface | $body | Message body, if any. |
array | $headers | Headers for the message, if any. |
\InvalidArgumentException | for any invalid value. |
Definition at line 86 of file core/Classes/Http/Request.php.
References Message\$body, Message\$headers, Request\$method, Request\$uri, Message\assertHeaders(), Message\filterHeaders(), and Request\validateMethod().
getHeader | ( | $header | ) |
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.
string | $name | Case-insensitive header field name. |
Implements MessageInterface.
Definition at line 164 of file core/Classes/Http/Request.php.
References Request\getHostFromUri(), and Message\hasHeader().
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.
Implements MessageInterface.
Definition at line 141 of file core/Classes/Http/Request.php.
References Message\$headers, Request\getHostFromUri(), and Message\hasHeader().
|
protected |
Retrieve the host from the URI instance
Definition at line 177 of file core/Classes/Http/Request.php.
Referenced by Request\getHeader(), and Request\getHeaders().
getMethod | ( | ) |
Retrieves the HTTP method of the request, defaults to GET
Implements RequestInterface.
Definition at line 253 of file core/Classes/Http/Request.php.
getRequestTarget | ( | ) |
Retrieves the message's request target.
Retrieves the message's request-target either as it will appear (for clients), as it appeared at request (for servers), or as it was specified for the instance (see withRequestTarget()).
In most cases, this will be the origin-form of the composed URI, unless a value was provided to the concrete implementation (see withRequestTarget() below).
If no URI is available, and no request-target has been specifically provided, this method MUST return the string "/".
Implements RequestInterface.
Definition at line 200 of file core/Classes/Http/Request.php.
References Request\$requestTarget.
getUri | ( | ) |
Retrieves the URI instance.
This method MUST return a UriInterface instance.
Returns a UriInterface instance representing the URI of the request.
Implements RequestInterface.
Definition at line 289 of file core/Classes/Http/Request.php.
References Request\$uri.
|
protected |
Validate the HTTP method, helper function.
NULL | string | $method |
\InvalidArgumentException | on invalid HTTP method. |
Definition at line 355 of file core/Classes/Http/Request.php.
References Request\$method.
Referenced by Request\__construct().
withMethod | ( | $method | ) |
Return an instance with the provided HTTP method.
While HTTP method names are typically all uppercase characters, HTTP method names are case-sensitive and thus implementations SHOULD NOT modify the given string.
This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the changed request method.
string | $method | Case-sensitive method. |
\InvalidArgumentException | for invalid HTTP methods. |
Implements RequestInterface.
Definition at line 273 of file core/Classes/Http/Request.php.
References Request\$method.
withRequestTarget | ( | $requestTarget | ) |
Return an instance with the specific request-target.
If the request needs a non-origin-form request-target — e.g., for specifying an absolute-form, authority-form, or asterisk-form — this method may be used to create an instance with the specified request-target, verbatim.
This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the changed request target.
(for the various request-target forms allowed in request messages) mixed $requestTarget Request
Implements RequestInterface.
Definition at line 238 of file core/Classes/Http/Request.php.
References Request\$requestTarget.
withUri | ( | UriInterface | $uri, |
$preserveHost = false |
|||
) |
Returns an instance with the provided URI.
This method MUST update the Host header of the returned request by default if the URI contains a host component. If the URI does not contain a host component, any pre-existing Host header MUST be carried over to the returned request.
You can opt-in to preserving the original state of the Host header by setting $preserveHost
to true
. When $preserveHost
is set to true
, this method interacts with the Host header in the following ways:
This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new UriInterface instance.
Implements RequestInterface.
Definition at line 325 of file core/Classes/Http/Request.php.
References Request\$uri, UriInterface\getHost(), and UriInterface\getPort().
|
protected |
Definition at line 44 of file core/Classes/Http/Request.php.
Referenced by ServerRequest\__construct(), Request\__construct(), Request\validateMethod(), and Request\withMethod().
|
protected |
Definition at line 37 of file core/Classes/Http/Request.php.
Referenced by Request\getRequestTarget(), and Request\withRequestTarget().
|
protected |
Definition at line 51 of file core/Classes/Http/Request.php.
|
protected |
Definition at line 75 of file core/Classes/Http/Request.php.
Referenced by ServerRequest\__construct(), Request\__construct(), Request\getUri(), and Request\withUri().