Documentation

rex_response
in package

HTTP1.1 Client Cache Features.

Table of Contents

Constants

HTTP_BAD_REQUEST  = '400 Bad Request'
HTTP_FORBIDDEN  = '403 Forbidden'
HTTP_INTERNAL_ERROR  = '500 Internal Server Error'
HTTP_MOVED_PERMANENTLY  = '301 Moved Permanently'
HTTP_MOVED_TEMPORARILY  = '307 Temporary Redirect'
HTTP_NOT_FOUND  = '404 Not Found'
HTTP_NOT_MODIFIED  = '304 Not Modified'
HTTP_OK  = '200 OK'
HTTP_PARTIAL_CONTENT  = '206 Partial Content'
HTTP_RANGE_NOT_SATISFIABLE  = '416 Range Not Satisfiable'
HTTP_SERVICE_UNAVAILABLE  = '503 Service Unavailable'
HTTP_UNAUTHORIZED  = '401 Unauthorized'

Methods

cleanOutputBuffers()  : void
Cleans all output buffers.
clearCookie()  : void
Clear the given cookie by name.
enforceHttps()  : void
getNonce()  : string
Returns a request save NONCE für CSP Headers and Implemntations.
getStatus()  : string
Returns the HTTP Status code.
preload()  : void
Set a file to be preload via http link header.
sendCacheControl()  : void
Sends the cache control header.
sendContent()  : void
Sends content to the client.
sendContentType()  : void
Sends the content type header.
sendCookie()  : void
sendEtag()  : void|never
Checks if content has changed by the etag cachekey.
sendFile()  : void|never
Sends a file to client.
sendJson()  : void
sendLastModified()  : void|never
Checks if content has changed by the last modified timestamp.
sendPage()  : void
Sends a page to client.
sendRedirect()  : never
Redirects to a URL.
sendResource()  : void
Sends a resource to the client.
setHeader()  : void
Set a http response header. A existing header with the same name will be overridden.
setStatus()  : void
Sets the HTTP Status code.
sendGzip()  : string
Encodes the content with GZIP/X-GZIP if the browser supports one of them.

Constants

HTTP_BAD_REQUEST

public mixed HTTP_BAD_REQUEST = '400 Bad Request'

HTTP_FORBIDDEN

public mixed HTTP_FORBIDDEN = '403 Forbidden'

HTTP_INTERNAL_ERROR

public mixed HTTP_INTERNAL_ERROR = '500 Internal Server Error'

HTTP_MOVED_PERMANENTLY

public mixed HTTP_MOVED_PERMANENTLY = '301 Moved Permanently'

HTTP_MOVED_TEMPORARILY

public mixed HTTP_MOVED_TEMPORARILY = '307 Temporary Redirect'

HTTP_NOT_FOUND

public mixed HTTP_NOT_FOUND = '404 Not Found'

HTTP_NOT_MODIFIED

public mixed HTTP_NOT_MODIFIED = '304 Not Modified'

HTTP_PARTIAL_CONTENT

public mixed HTTP_PARTIAL_CONTENT = '206 Partial Content'

HTTP_RANGE_NOT_SATISFIABLE

public mixed HTTP_RANGE_NOT_SATISFIABLE = '416 Range Not Satisfiable'

HTTP_SERVICE_UNAVAILABLE

public mixed HTTP_SERVICE_UNAVAILABLE = '503 Service Unavailable'

HTTP_UNAUTHORIZED

public mixed HTTP_UNAUTHORIZED = '401 Unauthorized'

Methods

cleanOutputBuffers()

Cleans all output buffers.

public static cleanOutputBuffers() : void

clearCookie()

Clear the given cookie by name.

public static clearCookie(string $name[, array{path?: string, domain?: ?string, secure?: bool, httponly?: bool, samesite?: ?string} $options = [] ]) : void

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

Parameters
$name : string

The name of the cookie

$options : array{path?: string, domain?: ?string, secure?: bool, httponly?: bool, samesite?: ?string} = []

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

Tags
throws
InvalidArgumentException

enforceHttps()

public static enforceHttps() : void

getNonce()

Returns a request save NONCE für CSP Headers and Implemntations.

public static getNonce() : string
Return values
string

getStatus()

Returns the HTTP Status code.

public static getStatus() : string
Return values
string

preload()

Set a file to be preload via http link header.

public static preload(string $file, string $type, string $mimeType) : void
Parameters
$file : string
$type : string
$mimeType : string

sendCacheControl()

Sends the cache control header.

public static sendCacheControl([string $cacheControl = 'must-revalidate, proxy-revalidate, private, no-cache, max-age=0' ]) : void
Parameters
$cacheControl : string = 'must-revalidate, proxy-revalidate, private, no-cache, max-age=0'

sendContent()

Sends content to the client.

public static sendContent(string $content[, string|null $contentType = null ][, int|null $lastModified = null ][, string|null $etag = null ]) : void
Parameters
$content : string

Content

$contentType : string|null = null

Content type

$lastModified : int|null = null

HTTP Last-Modified Timestamp

$etag : string|null = null

HTTP Cachekey to identify the cache

sendContentType()

Sends the content type header.

public static sendContentType([string $contentType = null ]) : void
Parameters
$contentType : string = null

sendCookie()

public static sendCookie(string $name, string|null $value[, DateTimeInterface, path?: string, domain?: ?string, secure?: bool, httponly?: bool, samesite?: ?string, raw?: bool} $options = [] ]) : void
Parameters
$name : string

The name of the cookie

$value : string|null

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

$options : DateTimeInterface, path?: string, domain?: ?string, secure?: bool, httponly?: bool, samesite?: ?string, raw?: bool} = []

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

Tags
throws
InvalidArgumentException

sendEtag()

Checks if content has changed by the etag cachekey.

public static sendEtag(string $cacheKey) : void|never

HTTP_IF_NONE_MATCH feature

Parameters
$cacheKey : string

HTTP Cachekey to identify the cache

Return values
void|never

sendFile()

Sends a file to client.

public static sendFile(string $file, string $contentType[, string $contentDisposition = 'inline' ][, string|null $filename = null ]) : void|never
Parameters
$file : string

File path

$contentType : string

Content type

$contentDisposition : string = 'inline'

Content disposition ("inline" or "attachment")

$filename : string|null = null

Custom Filename

Return values
void|never

sendJson()

public static sendJson(mixed $data[, int|null $lastModified = null ][, string|null $etag = null ]) : void
Parameters
$data : mixed

data to be json encoded and sent

$lastModified : int|null = null

HTTP Last-Modified Timestamp

$etag : string|null = null

HTTP Cachekey to identify the cache

sendLastModified()

Checks if content has changed by the last modified timestamp.

public static sendLastModified([int|null $lastModified = null ]) : void|never

HTTP_IF_MODIFIED_SINCE feature

Parameters
$lastModified : int|null = null

HTTP Last-Modified Timestamp

Return values
void|never

sendPage()

Sends a page to client.

public static sendPage(string $content[, int $lastModified = null ]) : void

The page content can be modified by the Extension Point OUTPUT_FILTER

Parameters
$content : string

Content of page

$lastModified : int = null

HTTP Last-Modified Timestamp

sendRedirect()

Redirects to a URL.

public static sendRedirect(string $url[, self::HTTP_MOVED_PERMANENTLY|self::HTTP_MOVED_TEMPORARILY|null $httpStatus = null ]) : never

NOTE: Execution will stop within this method!

Parameters
$url : string

URL

$httpStatus : self::HTTP_MOVED_PERMANENTLY|self::HTTP_MOVED_TEMPORARILY|null = null
Tags
throws
InvalidArgumentException
Return values
never

sendResource()

Sends a resource to the client.

public static sendResource(string $content[, string|null $contentType = null ][, int|null $lastModified = null ][, string|null $etag = null ][, string|null $contentDisposition = null ][, string|null $filename = null ]) : void
Parameters
$content : string

Content

$contentType : string|null = null

Content type

$lastModified : int|null = null

HTTP Last-Modified Timestamp

$etag : string|null = null

HTTP Cachekey to identify the cache

$contentDisposition : string|null = null

Content disposition ("inline" or "attachment")

$filename : string|null = null

Filename

setHeader()

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

public static setHeader(string $name, string $value) : void
Parameters
$name : string
$value : string

setStatus()

Sets the HTTP Status code.

public static setStatus(string $httpStatus) : void
Parameters
$httpStatus : string
Tags
throws
InvalidArgumentException

sendGzip()

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

protected static sendGzip(string $content) : string

HTTP_ACCEPT_ENCODING feature

Parameters
$content : string

Content

Return values
string

        
On this page

Search results