HeaderBag
final class HeaderBag (View source)
Stores HTTP header values under case-insensitive canonical names.
Methods
__construct(array $headers = [])
Initializes the bag while normalizing every supplied header name.
all()
Returns all headers keyed by their canonical names.
array
has(string $name)
Reports whether a header exists regardless of name casing or underscores.
bool
get(string $name, mixed $default = null)
Returns a header value by normalized name or the supplied fallback.
mixed
set(string $name, string $value)
Replaces the value stored under a normalized header name.
void
Details
__construct
__construct(array $headers = [])
Initializes the bag while normalizing every supplied header name.
all
array
all()
Returns all headers keyed by their canonical names.
has
bool
has(string $name)
Reports whether a header exists regardless of name casing or underscores.
get
mixed
get(string $name, mixed $default = null)
Returns a header value by normalized name or the supplied fallback.
set
void
set(string $name, string $value)
Replaces the value stored under a normalized header name.