HttpHeaders implements IteratorAggregate
Table of Contents
Interfaces
- IteratorAggregate
Constants
Methods
- __construct() : mixed
- add() : mixed
- Adds a header value.
- clear() : mixed
- Clears all headers.
- createFromString() : HttpHeaders
- Creates an object from a http response string.
- delete() : void
- Deletes a header or headers by its name.
- get() : null|string|array<string|int, string>
- Returns a header value by its name. If $returnArray is true then an array with multiple values is returned.
- getBoundary() : null|string
- Returns the boundary value of the Content-Type header.
- getCharset() : null|string
- Returns the charset part of the Content-Type header.
- getContentDisposition() : null|string
- Returns disposition-type part of the Content-Disposition header
- getContentType() : null|string
- Returns the content type part of the Content-Type header in lower case.
- getContentTypeAttribute() : null|string
- Returns the specified attribute part of the Content-Type header.
- getCookies() : HttpCookies
- Returns parsed cookies from 'set-cookie' headers.
- getFilename() : string|null
- Returns a filename from the Content-disposition header.
- getHeaders() : array<string|int, array<string|int, string>>
- Retuns the headers as a two-dimentional array ('name' => values).
- getIterator() : Traversable
- Retrieve an external iterator
- getReasonPhrase() : string
- getStatus() : int
- getVersion() : string|null
- has() : bool
- Returns true if a header is set.
- parseStatus() : $this
- set() : mixed
- Sets (replaces) a header value.
- setStatus() : $this
- Sets HTTP status code and prase.
- setVersion() : HttpHeaders
- toArray() : array<string|int, mixed>
- Returns headers as a raw array.
- toString() : string
- Returns the string representation for an HTTP request.
Constants
DEFAULT_HTTP_STATUS
public
mixed
DEFAULT_HTTP_STATUS
= 0
Methods
__construct()
public
__construct([array<string|int, string>|array<string|int, array<string|int, string>>|null $headers = null ]) : mixed
Parameters
- $headers : array<string|int, string>|array<string|int, array<string|int, string>>|null = null
add()
Adds a header value.
public
add(string $name, string|array<string|int, mixed> $value) : mixed
Parameters
- $name : string
- $value : string|array<string|int, mixed>
Tags
clear()
Clears all headers.
public
clear() : mixed
createFromString()
Creates an object from a http response string.
public
static createFromString(string $response) : HttpHeaders
Parameters
- $response : string
Return values
HttpHeadersdelete()
Deletes a header or headers by its name.
public
delete(string $name) : void
Parameters
- $name : string
get()
Returns a header value by its name. If $returnArray is true then an array with multiple values is returned.
public
get(string $name[, bool $returnArray = false ]) : null|string|array<string|int, string>
Parameters
- $name : string
- $returnArray : bool = false
Return values
null|string|array<string|int, string>getBoundary()
Returns the boundary value of the Content-Type header.
public
getBoundary() : null|string
Return values
null|stringgetCharset()
Returns the charset part of the Content-Type header.
public
getCharset() : null|string
Return values
null|stringgetContentDisposition()
Returns disposition-type part of the Content-Disposition header
public
getContentDisposition() : null|string
Return values
null|string —Disposition-type part of the Content-Disposition header if found or null otherwise.
getContentType()
Returns the content type part of the Content-Type header in lower case.
public
getContentType() : null|string
Return values
null|stringgetContentTypeAttribute()
Returns the specified attribute part of the Content-Type header.
public
getContentTypeAttribute(string $attribute) : null|string
Parameters
- $attribute : string
Return values
null|stringgetCookies()
Returns parsed cookies from 'set-cookie' headers.
public
getCookies() : HttpCookies
Return values
HttpCookiesgetFilename()
Returns a filename from the Content-disposition header.
public
getFilename() : string|null
Return values
string|null —Filename if it was found in the Content-disposition header or null otherwise.
getHeaders()
Retuns the headers as a two-dimentional array ('name' => values).
public
getHeaders() : array<string|int, array<string|int, string>>
Return values
array<string|int, array<string|int, string>>getIterator()
Retrieve an external iterator
public
getIterator() : Traversable
Tags
Return values
Traversable —An instance of an object implementing Iterator or Traversable
getReasonPhrase()
public
getReasonPhrase() : string
Return values
stringgetStatus()
public
getStatus() : int
Return values
intgetVersion()
public
getVersion() : string|null
Return values
string|nullhas()
Returns true if a header is set.
public
has(string $name) : bool
Parameters
- $name : string
Return values
boolparseStatus()
public
parseStatus(string $status) : $this
Parameters
- $status : string
Return values
$thisset()
Sets (replaces) a header value.
public
set(string $name, string|array<string|int, string> $value) : mixed
Parameters
- $name : string
- $value : string|array<string|int, string>
setStatus()
Sets HTTP status code and prase.
public
setStatus(int $status[, string|null $reasonPhrase = null ]) : $this
Parameters
- $status : int
- $reasonPhrase : string|null = null
Return values
$thissetVersion()
public
setVersion(string $version) : HttpHeaders
Parameters
- $version : string
Return values
HttpHeaderstoArray()
Returns headers as a raw array.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>toString()
Returns the string representation for an HTTP request.
public
toString() : string