TYPO3
7.6
|
Public Member Functions | |
getProtocolVersion () | |
withProtocolVersion ($version) | |
getHeaders () | |
hasHeader ($name) | |
getHeader ($name) | |
getHeaderLine ($name) | |
withHeader ($name, $value) | |
withAddedHeader ($name, $value) | |
withoutHeader ($name) | |
getBody () | |
withBody (StreamInterface $body) | |
filter ($value) | |
validateHeaderName ($name) | |
isValidHeaderValue ($value) | |
Protected Member Functions | |
assertHeaders (array $headers) | |
filterHeaders (array $originalHeaders) | |
arrayContainsOnlyStrings (array $data) | |
validateHeaderValues (array $values) | |
Protected Attributes | |
$protocolVersion = '1.1' | |
$headers = array() | |
$lowercasedHeaderNames = array() | |
$body | |
Default implementation for the MessageInterface of the PSR-7 standard It is the base for any request or response for PSR-7.
Highly inspired by https://github.com/phly/http/
Definition at line 28 of file typo3/sysext/core/Classes/Http/Message.php.
|
protected |
Helper function to test if an array contains only strings
array | $data |
Definition at line 361 of file typo3/sysext/core/Classes/Http/Message.php.
Referenced by Message\withAddedHeader(), and Message\withHeader().
|
protected |
Ensure header names and values are valid.
array | $headers |
\InvalidArgumentException |
Definition at line 318 of file typo3/sysext/core/Classes/Http/Message.php.
References Message\isValidHeaderValue(), and Message\validateHeaderName().
Referenced by Request\__construct(), and Response\__construct().
filter | ( | $value | ) |
Filter a header value
Ensures CRLF header injection vectors are filtered.
Per RFC 7230, only VISIBLE ASCII characters, spaces, and horizontal tabs are allowed in values; header continuations MUST consist of a single CRLF sequence followed by a space or horizontal tab.
This method filters any values not allowed from the string, and is lossy.
string | $value |
Definition at line 400 of file typo3/sysext/core/Classes/Http/Message.php.
|
protected |
Filter a set of headers to ensure they are in the correct internal format.
Used by message constructors to allow setting all initial headers at once.
array | $originalHeaders | Headers to filter. |
Definition at line 339 of file typo3/sysext/core/Classes/Http/Message.php.
References Message\$headers.
Referenced by Request\__construct(), and Response\__construct().
getBody | ( | ) |
Gets the body of the message.
Implements MessageInterface.
Definition at line 287 of file typo3/sysext/core/Classes/Http/Message.php.
References Message\$body.
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.
string | $name | Case-insensitive header field name. |
Implements MessageInterface.
Definition at line 145 of file typo3/sysext/core/Classes/Http/Message.php.
References Message\hasHeader().
Referenced by Message\getHeaderLine().
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 MessageInterface.
Definition at line 178 of file typo3/sysext/core/Classes/Http/Message.php.
References Message\getHeader().
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 113 of file typo3/sysext/core/Classes/Http/Message.php.
References Message\$headers.
getProtocolVersion | ( | ) |
Retrieves the HTTP protocol version as a string.
The string MUST contain only the HTTP version number (e.g., "1.1", "1.0").
Implements MessageInterface.
Definition at line 63 of file typo3/sysext/core/Classes/Http/Message.php.
References Message\$protocolVersion.
hasHeader | ( | $name | ) |
Checks if a header exists by the given case-insensitive name.
string | $name | Case-insensitive header field name. |
Implements MessageInterface.
Definition at line 126 of file typo3/sysext/core/Classes/Http/Message.php.
Referenced by Message\getHeader(), Request\getHeader(), Request\getHeaders(), Message\withAddedHeader(), and Message\withoutHeader().
isValidHeaderValue | ( | $value | ) |
Checks if an HTTP header value is valid.
Per RFC 7230, only VISIBLE ASCII characters, spaces, and horizontal tabs are allowed in values; header continuations MUST consist of a single CRLF sequence followed by a space or horizontal tab.
string | $value |
Definition at line 459 of file typo3/sysext/core/Classes/Http/Message.php.
Referenced by Message\assertHeaders(), and Message\validateHeaderValues().
validateHeaderName | ( | $name | ) |
Check whether or not a header name is valid and throw an exception.
string | $name |
\InvalidArgumentException |
Definition at line 441 of file typo3/sysext/core/Classes/Http/Message.php.
Referenced by Message\assertHeaders(), Message\withAddedHeader(), and Message\withHeader().
|
protected |
Assert that the provided header values are valid.
string[] | $values |
\InvalidArgumentException |
Definition at line 375 of file typo3/sysext/core/Classes/Http/Message.php.
References Message\isValidHeaderValue().
Referenced by Message\withAddedHeader(), and Message\withHeader().
withAddedHeader | ( | $name, | |
$value | |||
) |
Return an instance with the specified header appended with the given value.
Existing values for the specified header will be maintained. The new value(s) will be appended to the existing list. If the header did not exist previously, it will be added.
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 header and/or value.
string | $name | Case-insensitive header field name to add. |
string|string[] | $value Header value(s). |
\InvalidArgumentException | for invalid header names or values. |
Implements MessageInterface.
Definition at line 238 of file typo3/sysext/core/Classes/Http/Message.php.
References Message\arrayContainsOnlyStrings(), Message\hasHeader(), Message\validateHeaderName(), Message\validateHeaderValues(), and Message\withHeader().
withBody | ( | StreamInterface | $body | ) |
Return an instance with the specified message body.
The body MUST be a StreamInterface object.
This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return a new instance that has the new body stream.
\Psr\Http\Message\StreamInterface | $body | Body. |
\InvalidArgumentException | When the body is not valid. |
Implements MessageInterface.
Definition at line 305 of file typo3/sysext/core/Classes/Http/Message.php.
References Message\$body.
withHeader | ( | $name, | |
$value | |||
) |
Return an instance with the provided value replacing the specified header.
While header names are case-insensitive, the casing of the header will be preserved by this function, and returned from getHeaders().
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 and/or updated header and value.
string | $name | Case-insensitive header field name. |
string|string[] | $value Header value(s). |
\InvalidArgumentException | for invalid header names or values. |
Implements MessageInterface.
Definition at line 202 of file typo3/sysext/core/Classes/Http/Message.php.
References Message\arrayContainsOnlyStrings(), Message\validateHeaderName(), and Message\validateHeaderValues().
Referenced by Message\withAddedHeader().
withoutHeader | ( | $name | ) |
Return an instance without the specified header.
Header resolution MUST be done without case-sensitivity.
This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that removes the named header.
string | $name | Case-insensitive header field name to remove. |
Implements MessageInterface.
Definition at line 269 of file typo3/sysext/core/Classes/Http/Message.php.
References Message\hasHeader().
withProtocolVersion | ( | $version | ) |
Return an instance with the specified HTTP protocol version.
The version string MUST contain only the HTTP version number (e.g., "1.1", "1.0").
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 protocol version.
string | $version | HTTP protocol version |
Implements MessageInterface.
Definition at line 81 of file typo3/sysext/core/Classes/Http/Message.php.
|
protected |
Definition at line 54 of file typo3/sysext/core/Classes/Http/Message.php.
Referenced by ServerRequest\__construct(), Request\__construct(), Response\__construct(), Message\getBody(), and Message\withBody().
|
protected |
Definition at line 41 of file typo3/sysext/core/Classes/Http/Message.php.
Referenced by ServerRequest\__construct(), Request\__construct(), Response\__construct(), Message\filterHeaders(), Message\getHeaders(), and Request\getHeaders().
|
protected |
Definition at line 48 of file typo3/sysext/core/Classes/Http/Message.php.
|
protected |
Definition at line 34 of file typo3/sysext/core/Classes/Http/Message.php.
Referenced by Message\getProtocolVersion().