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

$filename

$filename : string

Download file name

Type

string

$file

$file : \CodeIgniter\HTTP\File?

Download for file

Type

\CodeIgniter\HTTP\File?

$setMime

$setMime : boolean

mime set flag

Type

boolean

$binary

$binary : string

Download for binary

Type

string

$reason

$reason : string

Download reason

Type

string

$charset

$charset : string

Download charset

Type

string

$pretend

$pretend : boolean

pretend

Type

boolean

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(string  $filename, boolean  $setMime) 

Constructor.

Parameters

string $filename
boolean $setMime

setBinary()

setBinary(string  $binary) 

set download for binary string.

Parameters

string $binary

setFilePath()

setFilePath(string  $filepath) 

set download for file.

Parameters

string $filepath

setFileName()

setFileName(string  $filename) : $this

set name for the download.

Parameters

string $filename

Returns

$this

getContentLength()

getContentLength() : integer

get content length.

Returns

integer

getStatusCode()

getStatusCode() : integer

Gets the response status code.

The status code is a 3-digit integer result code of the getServer's attempt to understand and satisfy the request.

Returns

integer —

Status code.

setStatusCode()

setStatusCode(\CodeIgniter\HTTP\int  $code, \CodeIgniter\HTTP\string  $reason = '') : self

Return an instance with the specified status code and, optionally, reason phrase.

If no reason phrase is specified, will default recommended reason phrase for the response's status code.

Parameters

\CodeIgniter\HTTP\int $code

The 3-digit integer result code to set.

\CodeIgniter\HTTP\string $reason

The reason phrase to use with the provided status code; if none is provided, will default to the IANA name.

Throws

\CodeIgniter\Exceptions\DownloadException

Returns

self

getReason()

getReason() : string

Gets the response response phrase associated with the status code.

Returns

string

setContentType()

setContentType(\CodeIgniter\HTTP\string  $mime, \CodeIgniter\HTTP\string  $charset = 'UTF-8') : \CodeIgniter\HTTP\ResponseInterface

Sets the Content Type header for this response with the mime type and, optionally, the charset.

Parameters

\CodeIgniter\HTTP\string $mime
\CodeIgniter\HTTP\string $charset

Returns

\CodeIgniter\HTTP\ResponseInterface

noCache()

noCache() 

Sets the appropriate headers to ensure this response is not cached by the browsers.

setCache()

setCache(array  $options = array()) : \CodeIgniter\HTTP\ResponseInterface

A shortcut method that allows the developer to set all of the cache-control headers in one method call.

The options array is used to provide the cache-control directives for the header. It might look something like:

 $options = [
     'max-age'  => 300,
     's-maxage' => 900
     'etag'     => 'abcde',
 ];

Typical options are:

  • etag
  • last-modified
  • max-age
  • s-maxage
  • private
  • public
  • must-revalidate
  • proxy-revalidate
  • no-transform

Parameters

array $options

Throws

\CodeIgniter\Exceptions\DownloadException

Returns

\CodeIgniter\HTTP\ResponseInterface

setLastModified()

setLastModified(string|\DateTime  $date) 

Sets the Last-Modified date header.

$date can be either a string representation of the date or, preferably, an instance of DateTime.

Parameters

string|\DateTime $date

pretend()

pretend(boolean  $pretend = true) : $this

For unit testing, don't actually send headers.

Parameters

boolean $pretend

Returns

$this

buildHeaders()

buildHeaders() 

set header for file download.

sendBody()

sendBody() : \CodeIgniter\HTTP\DownloadResponse

output download file text.

Throws

\CodeIgniter\Exceptions\DownloadException

Returns

\CodeIgniter\HTTP\DownloadResponse

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

setContentTypeByMimeType()

setContentTypeByMimeType() 

Set content type by guessing mime type from file extension

getDownloadFileName()

getDownloadFileName() : string

get download filename.

Returns

string

getContentDisposition()

getContentDisposition() : string

get Content-Disposition Header string.

Returns

string