Basic HTTP headers collection functionality Handles aggregation of headers

see
package Default

 Methods

Add a Header to this container, for raw values @see addHeaderLine() and addHeaders()

addHeader(\Zend\Http\Header\HeaderInterface $header) : \Zend\Http\Headers

Parameters

$header

\Zend\Http\Header\HeaderInterface

Returns

\Zend\Http\Headers

Add a raw header line, either in name => value, or as a single string 'name: value'

addHeaderLine(string $headerFieldNameOrLine, string $fieldValue = null) : \Zend\Http\Headers

This method allows for lazy-loading in that the parsing and instantiation of Header object will be delayed until they are retrieved by either get() or current()

Parameters

$headerFieldNameOrLine

string

$fieldValue

string

optional

Exceptions

\Zend\Http\Exception\InvalidArgumentException

Returns

\Zend\Http\Headers

Add many headers at once

addHeaders(array|\Traversable $headers) : \Zend\Http\Headers

Expects an array (or Traversable object) of type/value pairs.

Parameters

$headers

array\Traversable

Exceptions

\Zend\Http\Exception\InvalidArgumentException

Returns

\Zend\Http\Headers

Clear all headers

clearHeaders() : \Zend\Http\Headers

Removes all headers from queue

Returns

\Zend\Http\Headers

Return the number of headers in this contain, if all headers have not been parsed, actual count could increase if MultipleHeader objects exist in the Request/Response. If you need an exact count, iterate

count() : integer

Returns

integercount of currently known headers

Return the current value for this iterator, lazy loading it if need be

current() : array | \Zend\Http\Header\HeaderInterface

Returns

array\Zend\Http\Header\HeaderInterface

By calling this, it will force parsing and loading of all headers, after this count() will be accurate

forceLoading() : boolean

Returns

boolean

Populates headers from string representation

fromString(string $string) : \Zend\Http\Headers
Static

Parses a string for headers, and aggregates them, in order, in the current instance, primarily as strings until they are needed (they will be lazy loaded)

Parameters

$string

string

Exceptions

\Zend\Http\Exception\RuntimeException

Returns

\Zend\Http\Headers

Get all headers of a certain name/type

get(string $name) : boolean | \Zend\Http\Header\HeaderInterface | \ArrayIterator

Parameters

$name

string

Returns

boolean\Zend\Http\Header\HeaderInterface\ArrayIterator

Return an instance of a PluginClassLocator, lazyload and inject map if necessary

getPluginClassLoader() : \Zend\Loader\PluginClassLocator

Returns

\Zend\Loader\PluginClassLocator

Test for existence of a type of header

has(string $name) : boolean

Parameters

$name

string

Returns

boolean

Return the current key for this object as an iterator

key() : mixed

Returns

mixed

Advance the pointer for this object as an iterator

next() : void

Remove a Header from the container

removeHeader(\Zend\Http\Header\HeaderInterface $header) : boolean

Parameters

$header

\Zend\Http\Header\HeaderInterface

Returns

boolean

Reset the internal pointer for this object as an iterator

rewind() : void

Set an alternate implementation for the PluginClassLoader

setPluginClassLoader(\Zend\Loader\PluginClassLocator $pluginClassLoader) : \Zend\Http\Headers

Parameters

$pluginClassLoader

\Zend\Loader\PluginClassLocator

Returns

\Zend\Http\Headers

Return the headers container as an array

toArray() : array
todo determine how to produce single line headers, if they are supported

Returns

array

Render all headers at once

toString() : string

This method handles the normal iteration of headers; it is up to the concrete classes to prepend with the appropriate status/request line.

Returns

string

Is this iterator still valid?

valid() : boolean

Returns

boolean

Create array key from header name

createKey(string $name) : string
Static

Parameters

$name

string

Returns

string

lazyLoadHeader()

lazyLoadHeader($index) : mixed | void

Parameters

$index

Returns

mixedvoid

 Properties

 

Array of header array information or Header instances

$headers : array

Default

array()
 

key names for $headers array

$headersKeys : array

Default

array()
 

$pluginClassLoader

$pluginClassLoader : \Zend\Loader\PluginClassLocator

Default

null