Constants

HTTP_OK

HTTP_OK = '200 OK'

HTTP_PARTIAL_CONTENT

HTTP_PARTIAL_CONTENT = '206 Partial Content'

HTTP_MOVED_PERMANENTLY

HTTP_MOVED_PERMANENTLY = '301 Moved Permanently'

HTTP_NOT_MODIFIED

HTTP_NOT_MODIFIED = '304 Not Modified'

HTTP_MOVED_TEMPORARILY

HTTP_MOVED_TEMPORARILY = '307 Temporary Redirect'

HTTP_NOT_FOUND

HTTP_NOT_FOUND = '404 Not Found'

HTTP_FORBIDDEN

HTTP_FORBIDDEN = '403 Forbidden'

HTTP_UNAUTHORIZED

HTTP_UNAUTHORIZED = '401 Unauthorized'

HTTP_RANGE_NOT_SATISFIABLE

HTTP_RANGE_NOT_SATISFIABLE = '416 Range Not Satisfiable'

HTTP_INTERNAL_ERROR

HTTP_INTERNAL_ERROR = '500 Internal Server Error'

HTTP_SERVICE_UNAVAILABLE

HTTP_SERVICE_UNAVAILABLE = '503 Service Unavailable'

Methods

setStatus()

setStatus(string  $httpStatus) : mixed

Sets the HTTP Status code.

Parameters

string $httpStatus

Throws

\InvalidArgumentException

Returns

mixed —

getStatus()

getStatus() : string

Returns the HTTP Status code.

Returns

string —

setHeader()

setHeader(string  $name, string  $value) : mixed

Set a http response header. A existing header with the same name will be overridden.

Parameters

string $name
string $value

Returns

mixed —

preload()

preload(string  $file, string  $type, string  $mimeType) : mixed

Set a file to be preload via http link header.

Parameters

string $file
string $type
string $mimeType

Returns

mixed —

sendRedirect()

sendRedirect(string  $url, mixed  $httpStatus = null) : mixed

Redirects to a URL.

NOTE: Execution will stop within this method!

Parameters

string $url

URL

mixed $httpStatus

Throws

\InvalidArgumentException

Returns

mixed —

sendFile()

sendFile(string  $file, string  $contentType, string  $contentDisposition = 'inline', null|string  $filename = null) : mixed

Sends a file to client.

Parameters

string $file

File path

string $contentType

Content type

string $contentDisposition

Content disposition ("inline" or "attachment")

null|string $filename

Custom Filename

Returns

mixed —

sendResource()

sendResource(string  $content, null|string  $contentType = null, null|int  $lastModified = null, null|string  $etag = null, null|string  $contentDisposition = null, null|string  $filename = null) : mixed

Sends a resource to the client.

Parameters

string $content

Content

null|string $contentType

Content type

null|int $lastModified

HTTP Last-Modified Timestamp

null|string $etag

HTTP Cachekey to identify the cache

null|string $contentDisposition

Content disposition ("inline" or "attachment")

null|string $filename

Filename

Returns

mixed —

sendPage()

sendPage(string  $content, int  $lastModified = null) : mixed

Sends a page to client.

The page content can be modified by the Extension Point OUTPUT_FILTER

Parameters

string $content

Content of page

int $lastModified

HTTP Last-Modified Timestamp

Returns

mixed —

sendContent()

sendContent(string  $content, string|null  $contentType = null, int|null  $lastModified = null, string|null  $etag = null) : mixed

Sends content to the client.

Parameters

string $content

Content

string|null $contentType

Content type

int|null $lastModified

HTTP Last-Modified Timestamp

string|null $etag

HTTP Cachekey to identify the cache

Returns

mixed —

sendJson()

sendJson(mixed  $data, int|null  $lastModified = null, string|null  $etag = null) : void

Parameters

mixed $data

data to be json encoded and sent

int|null $lastModified

HTTP Last-Modified Timestamp

string|null $etag

HTTP Cachekey to identify the cache

cleanOutputBuffers()

cleanOutputBuffers() : mixed

Cleans all output buffers.

Returns

mixed —

sendContentType()

sendContentType(string  $contentType = null) : mixed

Sends the content type header.

Parameters

string $contentType

Returns

mixed —

sendCacheControl()

sendCacheControl(mixed  $cacheControl = 'must-revalidate, proxy-revalidate, private, no-cache, max-age=0') : mixed

Sends the cache control header.

Parameters

mixed $cacheControl

Returns

mixed —

sendLastModified()

sendLastModified(int  $lastModified = null) : mixed

Checks if content has changed by the last modified timestamp.

HTTP_IF_MODIFIED_SINCE feature

Parameters

int $lastModified

HTTP Last-Modified Timestamp

Returns

mixed —

sendEtag()

sendEtag(string  $cacheKey) : mixed

Checks if content has changed by the etag cachekey.

HTTP_IF_NONE_MATCH feature

Parameters

string $cacheKey

HTTP Cachekey to identify the cache

Returns

mixed —

sendCookie()

sendCookie(string  $name, string|null  $value, array  $options = []) : mixed

Parameters

string $name

The name of the cookie

string|null $value

the value of the cookie, a empty value to delete the cookie

array $options

Different cookie Options. Supported keys are: "expires" int|string|DateTimeInterface The time the cookie expires "path" string The path on the server in which the cookie will be available on "domain" string|null The domain that the cookie is available to "secure" bool Whether the cookie should only be transmitted over a secure HTTPS connection from the client "httponly" bool Whether the cookie will be made accessible only through the HTTP protocol "samesite" string|null Whether the cookie will be available for cross-site requests "raw" bool Whether the cookie value should be sent with no url encoding

Throws

\InvalidArgumentException

Returns

mixed —

clearCookie()

clearCookie(string  $name, array  $options = []) : void

Clear the given cookie by name.

You might pass additional options in case the name is not unique or the cookie is not stored on the current domain.

Parameters

string $name

The name of the cookie

array $options

Different cookie Options. Supported keys are: "path" string The path on the server in which the cookie will be available on "domain" string|null The domain that the cookie is available to "secure" bool Whether the cookie should only be transmitted over a secure HTTPS connection from the client "httponly" bool Whether the cookie will be made accessible only through the HTTP protocol "samesite" string|null Whether the cookie will be available for cross-site requests

Throws

\InvalidArgumentException

enforceHttps()

enforceHttps() : mixed

Returns

mixed —

sendGzip()

sendGzip(string  $content) : string

Encodes the content with GZIP/X-GZIP if the browser supports one of them.

HTTP_ACCEPT_ENCODING feature

Parameters

string $content

Content

Returns

string —