Zend Framework  3.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Headers Class Reference

Basic HTTP headers collection functionality Handles aggregation of headers. More...

Public Member Functions

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

Static Public Member Functions

static fromString ($string)
 Populates headers from string representation.
 

Protected Member Functions

 lazyLoadHeader ($index)
 

Static Protected Member Functions

static createKey ($name)
 Create array key from header name.
 

Protected Attributes

 $pluginClassLoader = null
 
 $headersKeys = []
 
 $headers = []
 

Detailed Description

Basic HTTP headers collection functionality Handles aggregation of headers.

See Also
http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2

Member Function Documentation

addHeader ( Header\HeaderInterface  $header)

Add a Header to this container, for raw values.

See Also
addHeaderLine() and addHeaders()
Parameters
Header\HeaderInterface$header
Returns
Headers
addHeaderLine (   $headerFieldNameOrLine,
  $fieldValue = null 
)

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

Exceptions
Exception\InvalidArgumentException
Parameters
string$headerFieldNameOrLine
string$fieldValueoptional
Returns
Headers
addHeaders (   $headers)

Add many headers at once.

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

Parameters
array | Traversable$headers
Returns
Headers
Exceptions
Exception\InvalidArgumentException
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
static createKey (   $name)
staticprotected

Create array key from header name.

Parameters
string$name
Returns
string
current ( )

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

Returns
array|Header
forceLoading ( )

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

Returns
bool
static fromString (   $string)
static

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)

Parameters
string$string
Returns
Headers
Exceptions
Exception\RuntimeException
get (   $name)

Get all headers of a certain name/type.

Parameters
string$name
Returns
bool|Header|ArrayIterator
getPluginClassLoader ( )

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

Returns
PluginClassLocator
has (   $name)

Test for existence of a type of header.

Parameters
string$name
Returns
bool
key ( )

Return the current key for this object as an iterator.

Returns
mixed
lazyLoadHeader (   $index)
protected
Parameters
$index
Returns
mixed|void
next ( )

Advance the pointer for this object as an iterator.

Returns
void
removeHeader ( Header\HeaderInterface  $header)

Remove a Header from the container.

Parameters
Header\HeaderInterface$header
Returns
bool
rewind ( )

Reset the internal pointer for this object as an iterator.

Returns
void
setPluginClassLoader ( PluginClassLocator  $pluginClassLoader)

Set an alternate implementation for the PluginClassLoader.

Parameters
\Zend\Loader\PluginClassLocator$pluginClassLoader
Returns
Headers
toArray ( )

Return the headers container as an array.

Todo:
determine how to produce single line headers, if they are supported
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

Member Data Documentation

$headers = []
protected
$headersKeys = []
protected
$pluginClassLoader = null
protected