HeaderUtil
in package
FinalYes
Table of Contents
Methods
- normalize() : array<string, string>
- Normalizes an array of header lines to format ["Name" => "Value (, Value2, Value3, ...)", ...] An exception is being made for Set-Cookie, which holds an array of values for each cookie.
- normalizeHeaderName() : string
- Normalizes a header name, e.g. "con TENT- lenGTh" -> "Content-Length"
- trimValues() : array<int, string>
- Trims whitespace from the header values.
- normalizeKV() : array{0: string|null, 1: scalar|bool|null}
- Extracts a key:value pair from the given value and returns it as 2-element array.
Methods
normalize()
Normalizes an array of header lines to format ["Name" => "Value (, Value2, Value3, ...)", ...] An exception is being made for Set-Cookie, which holds an array of values for each cookie.
public
static normalize(array<int|string, scalar|bool|array<int, scalar|bool|null>|null> $headers) : array<string, string>
For multiple cookies with the same name, only the last value will be kept.
Parameters
- $headers : array<int|string, scalar|bool|array<int, scalar|bool|null>|null>
Return values
array<string, string>normalizeHeaderName()
Normalizes a header name, e.g. "con TENT- lenGTh" -> "Content-Length"
public
static normalizeHeaderName(string $name) : string
Parameters
- $name : string
Tags
Return values
stringtrimValues()
Trims whitespace from the header values.
public
static trimValues(array<int, scalar|null> $values) : array<int, string>
Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field.
header-field = field-name ":" OWS field-value OWS OWS = *( SP / HTAB )
Parameters
- $values : array<int, scalar|null>
Tags
Return values
array<int, string> —$values
normalizeKV()
Extracts a key:value pair from the given value and returns it as 2-element array.
protected
static normalizeKV(mixed $value) : array{0: string|null, 1: scalar|bool|null}
If the key cannot be parsed, both array values will be null
.
Parameters
- $value : mixed