CodeIgniter v4.5 API

MessageInterface

Expected behavior of an HTTP message

Table of Contents

Methods

appendBody()  : $this
Appends data to the body of the current message.
appendHeader()  : $this
Adds an additional header value to any headers that accept multiple values (i.e. are an array or implement ArrayAccess)
getBody()  : string|null
Gets the body of the message.
getHeaderLine()  : string
Retrieves a comma-separated string of the values for a single header.
getProtocolVersion()  : string
Retrieves the HTTP protocol version as a string.
hasHeader()  : bool
Checks if a header exists by the given case-insensitive name.
header()  : Header|array<int, Header>|null
Returns a single Header object. If multiple headers with the same name exist, then will return an array of header objects.
headers()  : array<string, Header|array<int, Header>>
Returns an array containing all Headers.
populateHeaders()  : void
Populates the $headers array with any headers the server knows about.
prependHeader()  : $this
Adds an additional header value to any headers that accept multiple values (i.e. are an array or implement ArrayAccess)
removeHeader()  : $this
Removes a header from the list of headers we track.
setBody()  : $this
Sets the body of the current message.
setHeader()  : $this
Sets a header and it's value.
setProtocolVersion()  : $this
Sets the HTTP protocol version.

Methods

appendBody()

Appends data to the body of the current message.

public appendBody(string $data) : $this
Parameters
$data : string
Return values
$this

appendHeader()

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

public appendHeader(string $name, string|null $value) : $this
Parameters
$name : string
$value : string|null
Return values
$this

getBody()

Gets the body of the message.

public getBody() : string|null
Tags
TODO

Incompatible return type with PSR-7

Return values
string|null

getHeaderLine()

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

public getHeaderLine(string $name) : string

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
$name : string
Return values
string

getProtocolVersion()

Retrieves the HTTP protocol version as a string.

public getProtocolVersion() : string

The string MUST contain only the HTTP version number (e.g., "1.1", "1.0").

Return values
string

HTTP protocol version.

hasHeader()

Checks if a header exists by the given case-insensitive name.

public hasHeader(string $name) : bool
Parameters
$name : string

Case-insensitive header field name.

Return values
bool

Returns true if any header names match the given header name using a case-insensitive string comparison. Returns false if no matching header name is found in the message.

header()

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

public header(string $name) : Header|array<int, Header>|null
Parameters
$name : string
Return values
Header|array<int, Header>|null

headers()

Returns an array containing all Headers.

public headers() : array<string, Header|array<int, Header>>
Return values
array<string, Header|array<int, Header>>

An array of the Header objects

populateHeaders()

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

public populateHeaders() : void

prependHeader()

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

public prependHeader(string $name, string $value) : $this
Parameters
$name : string
$value : string
Return values
$this

removeHeader()

Removes a header from the list of headers we track.

public removeHeader(string $name) : $this
Parameters
$name : string
Return values
$this

setBody()

Sets the body of the current message.

public setBody(string $data) : $this
Parameters
$data : string
Return values
$this

setHeader()

Sets a header and it's value.

public setHeader(string $name, array<string|int, mixed>|string|null $value) : $this
Parameters
$name : string
$value : array<string|int, mixed>|string|null
Return values
$this

setProtocolVersion()

Sets the HTTP protocol version.

public setProtocolVersion(string $version) : $this
Parameters
$version : string
Tags
throws
HTTPException

For invalid protocols

Return values
$this

        
On this page

Search results