The header field labels are retained internally in lower-case. This is to comply with HTTP/2 requirements; while HTTP/1.x has no such requirement, lower-case is also recognized as valid.
Further, the header field values are retained and returned as Sapien\Request\Header objects, not strings.
final public setHeader(string $label, Header|string $value) : static
Overwrites the $label
HTTP header in the Response; a buffered equivalent of
header("$label: $value", true)
.
The method is fluent, allowing you to chain a call to another Response method.
final public setHeaders(array $headers) : static
Overwrites all previous headers on the Response, replacing them with the
new $headers
array. Each $headers
element key is the field label, and
the corresponding element value is the field value.
The method is fluent, allowing you to chain a call to another Response method.
final public addHeader(string $label, Header|string $value) : static
Appends to the $label
HTTP header in the Response, comma-separating it from
the existing value; a buffered equivalent of header("$label: $value", false)
.
The method is fluent, allowing you to chain a call to another Response method.
final public getHeader(string $label) : ?Header
Returns the $label
header from the Response, if it exists.
final public getHeaders() : array
Returns the array of Header objects in the Response.
final public hasHeader(string $label) : bool
Returns true
if the $label
header exists in the Response, false
if not.
final public unsetHeader(string $label) : static
Removes the $label
header from the Response.
The method is fluent, allowing you to chain a call to another Response method.
final public unsetHeaders() : static
Removes all headers from the buffer.
The method is fluent, allowing you to chain a call to another Response method.