HumHub Documentation (unofficial)

Headers
in package
implements Countable, Iterator

Basic HTTP headers collection functionality Handles aggregation of headers

Tags
see
http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2

Table of Contents

Interfaces

Countable
Iterator

Properties

$headers  : array<string|int, mixed>
$headersKeys  : array<string|int, mixed>
$pluginClassLoader  : PluginClassLocator

Methods

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

Properties

$headers

protected array<string|int, mixed> $headers = []

Array of header array information or Header instances

$headersKeys

protected array<string|int, mixed> $headersKeys = []

key names for $headers array

Methods

addHeader()

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

public addHeader(HeaderInterface $header) : $this
Parameters
$header : HeaderInterface
Return values
$this

addHeaderLine()

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

public addHeaderLine(string $headerFieldNameOrLine[, string $fieldValue = null ]) : $this

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 = null

optional

Tags
throws
InvalidArgumentException
Return values
$this

addHeaders()

Add many headers at once

public addHeaders(array<string|int, mixed>|Traversable $headers) : $this

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

Parameters
$headers : array<string|int, mixed>|Traversable
Tags
throws
InvalidArgumentException
Return values
$this

clearHeaders()

Clear all headers

public clearHeaders() : $this

Removes all headers from queue

Return values
$this

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

public count() : int
Attributes
#[ReturnTypeWillChange]
Return values
int

count of currently known headers

forceLoading()

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

public forceLoading() : bool
Return values
bool

fromString()

Populates headers from string representation

public static fromString(string $string) : 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
Tags
throws
RuntimeException
Return values
static

has()

Test for existence of a type of header

public has(string $name) : bool
Parameters
$name : string
Return values
bool

setPluginClassLoader()

Set an alternate implementation for the PluginClassLoader

public setPluginClassLoader(PluginClassLocator $pluginClassLoader) : $this
Parameters
$pluginClassLoader : PluginClassLocator
Return values
$this

toArray()

Return the headers container as an array

public toArray() : array<string|int, mixed>
Tags
todo

determine how to produce single line headers, if they are supported

Return values
array<string|int, mixed>

toString()

Render all headers at once

public 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.

Return values
string

createKey()

Create array key from header name

protected static createKey(string $name) : string
Parameters
$name : string
Return values
string

lazyLoadHeader()

protected lazyLoadHeader(int|string $index[, bool $isGeneric = false ]) : mixed|void
Parameters
$index : int|string
$isGeneric : bool = false

If true, there is no need to parse $index and call the ClassLoader.

Return values
mixed|void

        
On this page

Search results