WpOrgRequestsResponseHeaders
Case-insensitive dictionary for HTTP response headers with multi-value support.
Source: wp-includes/Requests/src/Response/Headers.php
Namespace: WpOrgRequestsResponse
Extends: WpOrgRequestsUtilityCaseInsensitiveDictionary
Implements: ArrayAccess, IteratorAggregate (via parent)
Inheritance
CaseInsensitiveDictionary provides the base ArrayAccess and IteratorAggregate implementation with case-insensitive key handling. Headers overrides key methods to support multiple values per header.
Parent: CaseInsensitiveDictionary
| Property | Type | Visibility | Description |
|---|---|---|---|
$data | array | protected | Actual stored data |
Parent methods:
offsetExists($offset)— Case-insensitive key checkoffsetGet($offset)— Returns single valueoffsetSet($offset, $value)— Replaces valueoffsetUnset($offset)— Removes keygetIterator()— ReturnsArrayIteratorgetAll()— Returns raw$dataarray
Methods (Overridden)
offsetGet()
public function offsetGet( string $offset ): string|nullGet a header value as a string. If the header has multiple values, they are joined with , (comma) per RFC 2616.
Warning: Avoid this for headers where commas appear unquoted in values (e.g.
Set-Cookie). UsegetValues()instead.
Warning: Avoid this for headers where commas appear unquoted in values (e.g. Set-Cookie). Use getValues() instead.
offsetSet()
public function offsetSet( string $offset, string $value ): voidWarning: Avoid this for headers where commas appear unquoted in values (e.g. Set-Cookie). Use getValues() instead.
Returns: Comma-joined string, or null if header not set.
getIterator()
public function getIterator(): ArrayIteratorSet a header value. Unlike the parent, this appends to an array of values rather than replacing. Each call adds another value for that header key.
Additional Methods
getValues()
public function getValues( string|int $offset ): array|nullThrows: Exception — If $offset is null (invalidset).
| Parameter | Type | Description |
|---|---|---|
$offset | string|int | Header name |
Returns a FilteredIterator that flattens multi-value arrays to comma-separated strings.
Get all values for a header as an array (without flattening).
flatten()
public function flatten( string|array $value ): stringReturns: Array of values, or null if not set.
| Parameter | Type | Description |
|---|---|---|
$value | string|array | Value to flatten |
Throws: InvalidArgument — When $offset is not a string or integer.
Flatten a value to a string. Arrays are imploded with ,.
Usage Notes
Returns: Flattened string.
// Internally: $data['set-cookie'] = ['cookie1=a', 'cookie2=b']
// offsetGet returns comma-joined:
$headers['set-cookie']; // "cookie1=a,cookie2=b"
// getValues returns array:
$headers->getValues('set-cookie'); // ['cookie1=a', 'cookie2=b']