HeaderHelper
class HeaderHelper (View source)
The HeaderHelper class.
Methods
Get header value.
Check whether or not a header name is valid.
Method to remove invalid CRLF injection from header value.
Method to validate a header value.
Method to validate protocol version format.
Convert values to array.
Validate is an array only contains string.
Convert every header values to one line and merge multiple values with comma.
Filter a header name to lowercase.
Prepare attachment headers to response object.
Details
at line line 33
static string
getValue(array $headers, string $name, mixed $default = null)
Get header value.
The key will be lower case to search header value and implode array to string by comma.
at line line 59
static boolean
isValidName(mixed $name)
Check whether or not a header name is valid.
This method based on phly/http
at line line 78
static string
filter(string $value)
Method to remove invalid CRLF injection from header value.
Follows RFC-7230, only allows visible ASCII characters, spaces and tabs in header value. every new line must only contains a single CRLF and a space or tab after it.
at line line 131
static boolean
isValidValue($value)
Method to validate a header value.
Follows RFC-7230, only allows visible ASCII characters, spaces and tabs in header value. every new line must only contains a single CRLF and a space or tab after it.
at line line 175
static boolean
isValidProtocolVersion(string $version)
Method to validate protocol version format.
Only allow 1.0, 1.1 and 2.
at line line 192
static array
allToArray(mixed $value)
Convert values to array.
at line line 224
static boolean
arrayOnlyContainsString(array $array)
Validate is an array only contains string.
at line line 252
static array|string
toHeaderLine(array $headers, bool $toString = false)
Convert every header values to one line and merge multiple values with comma.
at line line 280
static string
normalizeHeaderName(string $header)
Filter a header name to lowercase.
at line line 296
static ResponseInterface
prepareAttachmentHeaders(ResponseInterface $response, string $filename = null)
Prepare attachment headers to response object.