Methods |
public
|
__construct(Arrayable<string, string[]|string>|iterable<string, string[]|string> $items = [])
Creates a new HttpHeaders object
Creates a new HttpHeaders object
Implements
|
#
|
public
static
|
from(MessageInterface|Arrayable<string, string[]|string>|iterable<string, string[]|string>|string $value): static
Resolve a value to an HttpHeaders object
Resolve a value to an HttpHeaders object
If $value is a string, it is parsed as an HTTP message.
|
#
|
public
|
getContentLength(): int<0, max>|null
Get the value of the Content-Length header, or null if it is not set
Get the value of the Content-Length header, or null if it is not set
Throws
|
#
|
public
|
getMultipartBoundary(): ?string
Get the value of the Content-Type header's boundary parameter, or null if
it is not set
Get the value of the Content-Type header's boundary parameter, or null if
it is not set
Throws
|
#
|
public
|
getPreferences(): array<string, array{value: string, parameters: array<string, string>}>
Get preferences applied to the Prefer header as per [RFC7240]
Get preferences applied to the Prefer header as per [RFC7240]
|
#
|
public
static
|
mergePreferences(array<string, array{value: string, parameters?: array<string, string>}|string> $preferences): string
Merge preferences into a Prefer header value as per [RFC7240]
Merge preferences into a Prefer header value as per [RFC7240]
|
#
|
public
|
getRetryAfter(): int<0, max>|null
Get the value of the Retry-After header in seconds, or null if it has an
invalid value or is not set
Get the value of the Retry-After header in seconds, or null if it has an
invalid value or is not set
|
#
|
public
|
__toString(): string
|
#
|
public
|
addLine(string $line, bool $strict = false)
Parse and apply an HTTP header field or continuation thereof
Parse and apply an HTTP header field or continuation thereof
This method should be called once per HTTP header line. Each line must
have a trailing CRLF. If an empty line ("\r\n" ) is given,
{@see HttpHeadersInterface::hasLastLine()} returns true and subsequent
headers applied via {@see HttpHeadersInterface::addLine()} are flagged as
trailers. Methods other than {@see HttpHeadersInterface::trailers()} and
{@see HttpHeadersInterface::withoutTrailers()} make no distinction
between trailers and other headers.
Parameters
$strict |
If true , throw an exception if $line is not
[RFC7230]-compliant.
|
Implements
|
#
|
public
|
hasLastLine(): bool
Check if addLine() has received an empty line
Check if addLine() has received an empty line
Implements
|
#
|
public
|
add($key, $value)
Apply a value to a header, preserving any existing values
Apply a value to a header, preserving any existing values
Implements
|
#
|
public
|
set($key, $value)
Add or replace an item with a given key
Add or replace an item with a given key
Implements
|
#
|
public
|
unset($key)
Remove an item with a given key
Remove an item with a given key
Implements
|
#
|
public
|
merge($items, bool $addToExisting = false)
Merge the collection with the given items
Merge the collection with the given items
Implements
|
#
|
public
|
authorize(AccessTokenInterface $token, string $headerName = HttpHeader::AUTHORIZATION)
Apply an access token to the collection
Apply an access token to the collection
Implements
|
#
|
public
|
canonicalize()
Sort headers in the collection if necessary for compliance with [RFC7230]
Sort headers in the collection if necessary for compliance with [RFC7230]
Implements
|
#
|
public
|
sort()
Sort items in the collection
Sort items in the collection
Implements
|
#
|
public
|
reverse()
Reverse the order of items in the collection
Reverse the order of items in the collection
Implements
|
#
|
public
|
map<T is string[]|string|array{string, string[]}>(
callable(T, T|null $next, T|null $prev): string[] $callback,
int $mode = CollectionInterface::CALLBACK_USE_VALUE,
)
Pass each item in the collection to a callback and populate a new
collection with its return values
Pass each item in the collection to a callback and populate a new
collection with its return values
Implements
|
#
|
public
|
filter<T is string[]|string|array{string, string[]}>(
callable(T, T|null $next, T|null $prev): bool $callback,
int $mode = CollectionInterface::CALLBACK_USE_VALUE,
)
Reduce the collection to items that satisfy a callback
Reduce the collection to items that satisfy a callback
Implements
|
#
|
public
|
only(array $keys)
Reduce the collection to items with keys in an array
Reduce the collection to items with keys in an array
Implements
|
#
|
public
|
onlyIn(array $index)
Reduce the collection to items with keys in an index
Reduce the collection to items with keys in an index
Implements
|
#
|
public
|
except(array $keys)
Reduce the collection to items with keys not in an array
Reduce the collection to items with keys not in an array
Implements
|
#
|
public
|
exceptIn(array $index)
Reduce the collection to items with keys not in an index
Reduce the collection to items with keys not in an index
Implements
|
#
|
public
|
slice(int $offset, ?int $length = null)
Extract a slice of the collection
Extract a slice of the collection
Implements
|
#
|
public
|
toArray(): array
Get the object as an array
Get the object as an array
Implements
|
#
|
public
|
jsonSerialize(): array
|
#
|
public
|
pop(&$last = null)
Pop an item off the end of the collection
Pop an item off the end of the collection
Parameters
$last |
Receives the value removed from the collection,
or null if the collection is empty.
|
Implements
|
#
|
public
|
shift(&$first = null)
Shift an item off the beginning of the collection
Shift an item off the beginning of the collection
Parameters
$first |
Receives the value removed from the collection,
or null if the collection is empty.
|
Implements
|
#
|
public
|
trailers()
Reduce the collection to headers received after the HTTP message body
Reduce the collection to headers received after the HTTP message body
Implements
|
#
|
public
|
withoutTrailers()
Reduce the collection to headers received before the HTTP message body
Reduce the collection to headers received before the HTTP message body
Implements
|
#
|
public
|
getLines(string $format = '%s: %s', ?string $emptyFormat = null): array
Get header names and values in their original order as a list of HTTP
header fields, preserving the original case of…
Get header names and values in their original order as a list of HTTP
header fields, preserving the original case of each header
If $emptyFormat is given, it is used for headers with an empty value.
Implements
|
#
|
public
|
getHeaders(): array
Get an array that maps header names to values, preserving the original
case of the first appearance of each header
Get an array that maps header names to values, preserving the original
case of the first appearance of each header
Implements
|
#
|
public
|
getHeaderLines(): array
Get an array that maps lowercase header names to comma-separated values
Get an array that maps lowercase header names to comma-separated values
Implements
|
#
|
public
|
hasHeader(string $name): bool
True if a header is found in the collection
True if a header is found in the collection
Implements
|
#
|
public
|
getHeader(string $name): array
Get the value of a header as a list of values
Get the value of a header as a list of values
Implements
|
#
|
public
|
getHeaderValues(string $name): array
Get the value of a header as a list of values, splitting any
comma-separated values
Get the value of a header as a list of values, splitting any
comma-separated values
Implements
|
#
|
public
|
getHeaderLine(string $name): string
Get the comma-separated values of a header
Get the comma-separated values of a header
Implements
|
#
|
public
|
getFirstHeaderLine(string $name): string
Get the first value of a header after splitting any comma-separated
values
Get the first value of a header after splitting any comma-separated
values
Implements
|
#
|
public
|
getLastHeaderLine(string $name): string
Get the last value of a header after splitting any comma-separated values
Get the last value of a header after splitting any comma-separated values
Implements
|
#
|
public
|
getOneHeaderLine(string $name, bool $orSame = false): string
Get the only value of a header after splitting any comma-separated values
Get the only value of a header after splitting any comma-separated values
An exception is thrown if the header has more than one value.
Implements
|
#
|
protected
|
headers(): Generator<string, string>
|
#
|
protected
|
compareItems(string[] $a, string[] $b): int
|
#
|
protected
|
filterName(string $name): string
|
#
|
protected
|
filterValue(string $value): string
|
#
|
protected
|
maybeReplaceHeaders(
array<int, non-empty-array<string, string>>|null $headers,
array<string, int[]> $index,
bool $filterHeaders = false,
): static
|
#
|
protected
|
replaceHeaders(array<int, non-empty-array<string, string>>|null $headers, array<string, int[]> $index): static
|
#
|
protected
|
doGetHeaders(bool $preserveCase = false): array<string, string[]>
|
#
|
protected
|
getIndexHeaders(array<string, int[]> $index): array<int, non-empty-array<string, string>>
|
#
|
protected
|
getIndexValues(
array<array<string, string>> $headers,
array<string, int[]> $index,
): array<string, array<array<string, string>>>
|
#
|
protected
|
generateItems(
Arrayable<string, string[]|string>|iterable<string, string[]|string> $items,
): Generator<string, string[]|string>
|
#
|
protected
|
filterItems(array<string, string[]|string> $items): array<string, string[]>
|
#
|
protected
|
getItems(Arrayable<string, string[]|string>|iterable<string, string[]|string> $items): never
|
#
|