MediaWiki REL1_39
MediaWiki\Rest\HeaderContainer Class Reference

This is a container for storing headers. More...

Public Member Functions

 addHeader ( $name, $value)
 Set a header or append to an existing header.
 
 getHeader ( $name)
 Get the header with a particular name, or an empty array if there is no such header.
 
 getHeaderLine ( $name)
 Get the specified header concatenated into a comma-separated string.
 
 getHeaderLines ()
 Get all header lines.
 
 getHeaders ()
 Get header arrays indexed by original name.
 
 getRawHeaderLines ()
 Get an array of strings of the form "Name: Value", suitable for passing directly to header() to set response headers.
 
 hasHeader ( $name)
 Return true if the header exists, false otherwise.
 
 removeHeader ( $name)
 Remove a header.
 
 resetHeaders ( $headers=[])
 Erase any existing headers and replace them with the specified header arrays or values.
 
 setHeader ( $name, $value)
 Set or replace a header.
 

Detailed Description

This is a container for storing headers.

The header names are case-insensitive, but the case is preserved for methods that return headers in bulk. The header values are a comma-separated list, or equivalently, an array of strings.

Unlike PSR-7, the container is mutable.

Definition at line 12 of file HeaderContainer.php.

Member Function Documentation

◆ addHeader()

MediaWiki\Rest\HeaderContainer::addHeader ( $name,
$value )

Set a header or append to an existing header.

Parameters
string$name
string | string[]$value

Definition at line 90 of file HeaderContainer.php.

◆ getHeader()

MediaWiki\Rest\HeaderContainer::getHeader ( $name)

Get the header with a particular name, or an empty array if there is no such header.

Parameters
string$name
Returns
string[]

Definition at line 137 of file HeaderContainer.php.

◆ getHeaderLine()

MediaWiki\Rest\HeaderContainer::getHeaderLine ( $name)

Get the specified header concatenated into a comma-separated string.

If the header does not exist, an empty string is returned.

Parameters
string$name
Returns
string

Definition at line 161 of file HeaderContainer.php.

◆ getHeaderLines()

MediaWiki\Rest\HeaderContainer::getHeaderLines ( )

Get all header lines.

Returns
string[]

Definition at line 174 of file HeaderContainer.php.

◆ getHeaders()

MediaWiki\Rest\HeaderContainer::getHeaders ( )

Get header arrays indexed by original name.

Returns
string[][]

Definition at line 126 of file HeaderContainer.php.

◆ getRawHeaderLines()

MediaWiki\Rest\HeaderContainer::getRawHeaderLines ( )

Get an array of strings of the form "Name: Value", suitable for passing directly to header() to set response headers.

The PHP manual describes these strings as "raw HTTP headers", so we adopt that terminology.

Returns
string[] Header list (integer indexed)

Definition at line 185 of file HeaderContainer.php.

References $lines.

◆ hasHeader()

MediaWiki\Rest\HeaderContainer::hasHeader ( $name)

Return true if the header exists, false otherwise.

Parameters
string$name
Returns
bool

Definition at line 150 of file HeaderContainer.php.

◆ removeHeader()

MediaWiki\Rest\HeaderContainer::removeHeader ( $name)

Remove a header.

Parameters
string$name

Definition at line 111 of file HeaderContainer.php.

◆ resetHeaders()

MediaWiki\Rest\HeaderContainer::resetHeaders ( $headers = [])

Erase any existing headers and replace them with the specified header arrays or values.

Parameters
array$headers

Definition at line 23 of file HeaderContainer.php.

Referenced by MediaWiki\Rest\RequestBase\setHeaders().

◆ setHeader()

MediaWiki\Rest\HeaderContainer::setHeader ( $name,
$value )

Set or replace a header.

Parameters
string$name
string | string[]$value

Definition at line 71 of file HeaderContainer.php.


The documentation for this class was generated from the following file: