Properties

$headers

$headers : array

List of all HTTP request headers.

Type

array

$headerMap

$headerMap : array

Holds a map of lower-case header names and their normal-case key as it is in $headers.

Used for case-insensitive header access.

Type

array

$protocolVersion

$protocolVersion : string

Protocol version

Type

string

$validProtocolVersions

$validProtocolVersions : array

List of valid protocol versions

Type

array

$body

$body : string

Message body

Type

string

$ipAddress

$ipAddress : string

IP address of the current user.

Type

string

$proxyIPs

$proxyIPs : string|array

Proxy IPs

Type

string|array

$method

$method : string

Request method.

Type

string

$globals

$globals : array

Stores values we've retrieved from PHP globals.

Type

array

Methods

getBody()

getBody() : mixed

Returns the Message's body.

Returns

mixed

populateHeaders()

populateHeaders() 

Populates the $headers array with any headers the getServer knows about.

getHeaders()

getHeaders() : array

Returns an array containing all headers.

Returns

array —

An array of the request headers

getHeader()

getHeader(string  $name) : array|\CodeIgniter\HTTP\Header

Returns a single header object. If multiple headers with the same name exist, then will return an array of header objects.

Parameters

string $name

Returns

array|\CodeIgniter\HTTP\Header

hasHeader()

hasHeader(string  $name) : boolean

Determines whether a header exists.

Parameters

string $name

Returns

boolean

getHeaderLine()

getHeaderLine(string  $name) : string

Retrieves a comma-separated string of the values for a single header.

This method returns all of the header values of the given case-insensitive header name as a string concatenated together using a comma.

NOTE: Not all header values may be appropriately represented using comma concatenation. For such headers, use getHeader() instead and supply your own delimiter when concatenating.

Parameters

string $name

Returns

string

setHeader()

setHeader(string  $name, array|null|string  $value) : \CodeIgniter\HTTP\Message|\CodeIgniter\HTTP\Response

Sets a header and it's value.

Parameters

string $name
array|null|string $value

Returns

\CodeIgniter\HTTP\Message|\CodeIgniter\HTTP\Response

removeHeader()

removeHeader(string  $name) : \CodeIgniter\HTTP\Message

Removes a header from the list of headers we track.

Parameters

string $name

Returns

\CodeIgniter\HTTP\Message

appendHeader()

appendHeader(string  $name, string  $value) : \CodeIgniter\HTTP\Message

Adds an additional header value to any headers that accept multiple values (i.e. are an array or implement ArrayAccess)

Parameters

string $name
string $value

Returns

\CodeIgniter\HTTP\Message

prependHeader()

prependHeader(string  $name, string  $value) : \CodeIgniter\HTTP\Message

Adds an additional header value to any headers that accept multiple values (i.e. are an array or implement ArrayAccess)

Parameters

string $name
string $value

Returns

\CodeIgniter\HTTP\Message

getProtocolVersion()

getProtocolVersion() : string

Returns the HTTP Protocol Version.

Returns

string

setProtocolVersion()

setProtocolVersion(string  $version) : \CodeIgniter\HTTP\Message

Sets the HTTP protocol version.

Parameters

string $version

Returns

\CodeIgniter\HTTP\Message

__construct()

__construct(object  $config) 

Constructor.

Parameters

object $config

getIPAddress()

getIPAddress() : string

Gets the user's IP address.

Returns

string —

IP address

isValidIP()

isValidIP(string  $ip = null, string  $which = null) : boolean

Validate an IP address

Parameters

string $ip

IP Address

string $which

IP protocol: 'ipv4' or 'ipv6'

Returns

boolean

getMethod()

getMethod(boolean  $upper = false) : string

Get the request method.

Parameters

boolean $upper

Whether to return in upper or lower case.

Returns

string

setMethod()

setMethod(string  $method) : \CodeIgniter\HTTP\Request

Sets the request method. Used when spoofing the request.

Parameters

string $method

Returns

\CodeIgniter\HTTP\Request

getServer()

getServer(string|array|null  $index = null, integer|null  $filter = null, null  $flags = null) : mixed

Fetch an item from the $_SERVER array.

Parameters

string|array|null $index

Index for item to be fetched from $_SERVER

integer|null $filter

A filter name to be applied

null $flags

Returns

mixed

getEnv()

getEnv(null  $index = null, null  $filter = null, null  $flags = null) : mixed

Fetch an item from the $_ENV array.

Parameters

null $index

Index for item to be fetched from $_ENV

null $filter

A filter name to be applied

null $flags

Returns

mixed

setGlobal()

setGlobal(string  $method,   $value) : $this

Allows manually setting the value of PHP global, like $_GET, $_POST, etc.

Parameters

string $method
$value

Returns

$this

fetchGlobal()

fetchGlobal(string  $method, string|array|null  $index = null, integer|null  $filter = null, mixed  $flags = null) : mixed

Fetches one or more items from a global, like cookies, get, post, etc.

Can optionally filter the input when you retrieve it by passing in a filter.

If $type is an array, it must conform to the input allowed by the filter_input_array method.

http://php.net/manual/en/filter.filters.sanitize.php

Parameters

string $method

Input filter constant

string|array|null $index
integer|null $filter

Filter constant

mixed $flags

Returns

mixed

getHeaderName()

getHeaderName(string  $name) : string

Takes a header name in any case, and returns the normal-case version of the header.

Parameters

string $name

Returns

string

populateGlobals()

populateGlobals(string  $method) 

Saves a copy of the current state of one of several PHP globals so we can retrieve them later.

Parameters

string $method