Class Headers

Summary

Fully Qualified Name: Zend\Http\Headers
Implements: Countable, Iterator

Description

Basic HTTP headers collection functionality Handles aggregation of headers

Methods

Name Description Defined By
addHeader() Add a Header to this container, for raw values @see addHeaderLine() and addHeaders() Headers
addHeaderLine() Add a raw header line, either in name => value, or as a single string 'name: value' Headers
addHeaders() Add many headers at once Headers
clearHeaders() Clear all headers Headers
count() 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 Headers
current() Return the current value for this iterator, lazy loading it if need be Headers
forceLoading() By calling this, it will force parsing and loading of all headers, after this count() will be accurate Headers
fromString() Populates headers from string representation Headers
get() Get all headers of a certain name/type Headers
getPluginClassLoader() Return an instance of a PluginClassLocator, lazyload and inject map if necessary Headers
has() Test for existence of a type of header Headers
key() Return the current key for this object as an iterator Headers
next() Advance the pointer for this object as an iterator Headers
removeHeader() Remove a Header from the container Headers
rewind() Reset the internal pointer for this object as an iterator Headers
setPluginClassLoader() Set an alternate implementation for the PluginClassLoader Headers
toArray() Return the headers container as an array Headers
toString() Render all headers at once Headers
valid() Is this iterator still valid? Headers

Method Details

addHeader()

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

Parameter Name Type Description
$header \Header\HeaderInterface

Returns: \Headers

addHeaderLine()

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

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()

Parameter Name Type Description
$headerFieldNameOrLine string
$fieldValue string optional

Returns: \Headers

addHeaders()

Add many headers at once

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

Parameter Name Type Description
$headers array|\Traversable

Returns: \Headers

clearHeaders()

Clear all headers

Removes all headers from queue

Returns: \Headers

count()

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

Returns: int count of currently known headers

current()

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

Returns: array|\Header\HeaderInterface

forceLoading()

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

Returns: bool

fromString()

Populates headers from string representation

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)

Parameter Name Type Description
$string string

Returns: \Headers

get()

Get all headers of a certain name/type

Parameter Name Type Description
$name string

Returns: bool|\Header\HeaderInterface|\ArrayIterator

getPluginClassLoader()

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

Returns: \PluginClassLocator

has()

Test for existence of a type of header

Parameter Name Type Description
$name string

Returns: bool

key()

Return the current key for this object as an iterator

Returns: mixed

next()

Advance the pointer for this object as an iterator

Returns: void

removeHeader()

Remove a Header from the container

Parameter Name Type Description
$header \Header\HeaderInterface

Returns: bool

rewind()

Reset the internal pointer for this object as an iterator

Returns: void

setPluginClassLoader()

Set an alternate implementation for the PluginClassLoader

Parameter Name Type Description
$pluginClassLoader \Zend\Loader\PluginClassLocator

Returns: \Headers

toArray()

Return the headers container as an array

Returns: array

toString()

Render all headers at once

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

valid()

Is this iterator still valid?

Returns: bool

Top