Requests 2.0.11 API

Headers extends CaseInsensitiveDictionary
in package

Case-insensitive dictionary, suitable for HTTP headers

Table of Contents

Properties

$data  : array<string|int, mixed>
Actual item data

Methods

__construct()  : mixed
Creates a case insensitive dictionary.
flatten()  : string
Flattens a value into a string
getAll()  : array<string|int, mixed>
Get the headers as an array
getIterator()  : ArrayIterator
Get an iterator for the data
getValues()  : array<string|int, mixed>|null
Get all values for a given header
offsetExists()  : bool
Check if the given item exists
offsetGet()  : string|null
Get the given header
offsetSet()  : mixed
Set the given item
offsetUnset()  : mixed
Unset the given header

Properties

Methods

__construct()

Creates a case insensitive dictionary.

public __construct([array<string|int, mixed> $data = [] ]) : mixed
Parameters
$data : array<string|int, mixed> = []

Dictionary/map to convert to case-insensitive

flatten()

Flattens a value into a string

public flatten(string|array<string|int, mixed> $value) : string

Converts an array into a string by imploding values with a comma, as per RFC2616's rules for folding headers.

Parameters
$value : string|array<string|int, mixed>

Value to flatten

Tags
throws
InvalidArgument

When the passed argument is not a string or an array.

Return values
string

Flattened value

getAll()

Get the headers as an array

public getAll() : array<string|int, mixed>
Return values
array<string|int, mixed>

Header data

getIterator()

Get an iterator for the data

public getIterator() : ArrayIterator

Converts the internally stored values to a comma-separated string if there is more than one value for a key.

Return values
ArrayIterator

getValues()

Get all values for a given header

public getValues(string $offset) : array<string|int, mixed>|null
Parameters
$offset : string

Name of the header to retrieve.

Tags
throws
InvalidArgument

When the passed argument is not valid as an array key.

Return values
array<string|int, mixed>|null

Header values

offsetExists()

Check if the given item exists

public offsetExists(string $offset) : bool
Parameters
$offset : string

Item key

Return values
bool

Does the item exist?

offsetGet()

Get the given header

public offsetGet(string $offset) : string|null

Unlike Headers::getValues(), this returns a string. If there are multiple values, it concatenates them with a comma as per RFC2616.

Avoid using this where commas may be used unquoted in values, such as Set-Cookie headers.

Parameters
$offset : string

Name of the header to retrieve.

Return values
string|null

Header value

offsetSet()

Set the given item

public offsetSet(string $offset, string $value) : mixed
Parameters
$offset : string

Item name

$value : string

Item value

Tags
throws
Exception

On attempting to use dictionary as list (invalidset)

offsetUnset()

Unset the given header

public offsetUnset(string $offset) : mixed
Parameters
$offset : string

The key for the item to unset.


        
On this page

Search results