interface IResponse

HTTP response interface.

Constants

S100_CONTINUE

HTTP 1.1 response code

S101_SWITCHING_PROTOCOLS

HTTP 1.1 response code

S102_PROCESSING

HTTP 1.1 response code

S200_OK

HTTP 1.1 response code

S201_CREATED

HTTP 1.1 response code

S202_ACCEPTED

HTTP 1.1 response code

S203_NON_AUTHORITATIVE_INFORMATION

HTTP 1.1 response code

S204_NO_CONTENT

HTTP 1.1 response code

S205_RESET_CONTENT

HTTP 1.1 response code

S206_PARTIAL_CONTENT

HTTP 1.1 response code

S207_MULTI_STATUS

HTTP 1.1 response code

S208_ALREADY_REPORTED

HTTP 1.1 response code

S226_IM_USED

HTTP 1.1 response code

S300_MULTIPLE_CHOICES

HTTP 1.1 response code

S301_MOVED_PERMANENTLY

HTTP 1.1 response code

S302_FOUND

HTTP 1.1 response code

S303_SEE_OTHER

HTTP 1.1 response code

S303_POST_GET

HTTP 1.1 response code

S304_NOT_MODIFIED

HTTP 1.1 response code

S305_USE_PROXY

HTTP 1.1 response code

S307_TEMPORARY_REDIRECT

HTTP 1.1 response code

S308_PERMANENT_REDIRECT

HTTP 1.1 response code

S400_BAD_REQUEST

HTTP 1.1 response code

S401_UNAUTHORIZED

HTTP 1.1 response code

S402_PAYMENT_REQUIRED

HTTP 1.1 response code

S403_FORBIDDEN

HTTP 1.1 response code

S404_NOT_FOUND

HTTP 1.1 response code

S405_METHOD_NOT_ALLOWED

HTTP 1.1 response code

S406_NOT_ACCEPTABLE

HTTP 1.1 response code

S407_PROXY_AUTHENTICATION_REQUIRED

HTTP 1.1 response code

S408_REQUEST_TIMEOUT

HTTP 1.1 response code

S409_CONFLICT

HTTP 1.1 response code

S410_GONE

HTTP 1.1 response code

S411_LENGTH_REQUIRED

HTTP 1.1 response code

S412_PRECONDITION_FAILED

HTTP 1.1 response code

S413_REQUEST_ENTITY_TOO_LARGE

HTTP 1.1 response code

S414_REQUEST_URI_TOO_LONG

HTTP 1.1 response code

S415_UNSUPPORTED_MEDIA_TYPE

HTTP 1.1 response code

S416_REQUESTED_RANGE_NOT_SATISFIABLE

HTTP 1.1 response code

S417_EXPECTATION_FAILED

HTTP 1.1 response code

S421_MISDIRECTED_REQUEST

HTTP 1.1 response code

S422_UNPROCESSABLE_ENTITY

HTTP 1.1 response code

S423_LOCKED

HTTP 1.1 response code

S424_FAILED_DEPENDENCY

HTTP 1.1 response code

S426_UPGRADE_REQUIRED

HTTP 1.1 response code

S428_PRECONDITION_REQUIRED

HTTP 1.1 response code

S429_TOO_MANY_REQUESTS

HTTP 1.1 response code

S431_REQUEST_HEADER_FIELDS_TOO_LARGE

HTTP 1.1 response code

S451_UNAVAILABLE_FOR_LEGAL_REASONS

HTTP 1.1 response code

S500_INTERNAL_SERVER_ERROR

HTTP 1.1 response code

S501_NOT_IMPLEMENTED

HTTP 1.1 response code

S502_BAD_GATEWAY

HTTP 1.1 response code

S503_SERVICE_UNAVAILABLE

HTTP 1.1 response code

S504_GATEWAY_TIMEOUT

HTTP 1.1 response code

S505_HTTP_VERSION_NOT_SUPPORTED

HTTP 1.1 response code

S506_VARIANT_ALSO_NEGOTIATES

HTTP 1.1 response code

S507_INSUFFICIENT_STORAGE

HTTP 1.1 response code

S508_LOOP_DETECTED

HTTP 1.1 response code

S510_NOT_EXTENDED

HTTP 1.1 response code

S511_NETWORK_AUTHENTICATION_REQUIRED

HTTP 1.1 response code

REASON_PHRASES

SAME_SITE_LAX

SameSite cookie

SAME_SITE_STRICT

SameSite cookie

SAME_SITE_NONE

SameSite cookie

Methods

setCode(int $code, string|null $reason = null)

Sets HTTP response code.

int
getCode()

Returns HTTP response code.

setHeader(string $name, string $value)

Sends a HTTP header and replaces a previous one.

addHeader(string $name, string $value)

Adds HTTP header.

setContentType(string $type, string|null $charset = null)

Sends a Content-type HTTP header.

void
redirect(string $url, int $code = self::S302_FOUND)

Redirects to a new URL.

setExpiration(string|null $expire)

Sets the time (like '20 minutes') before a page cached on a browser expires, null means "must-revalidate".

bool
isSent()

Checks if headers have been sent.

string|null
getHeader(string $header)

Returns value of an HTTP header.

array
getHeaders()

Returns a associative array of headers to sent.

setCookie(string $name, string $value, string|int|DateTimeInterface $expire, string|null $path = null, string|null $domain = null, bool|null $secure = null, bool|null $httpOnly = null)

Sends a cookie.

deleteCookie(string $name, string|null $path = null, string|null $domain = null, bool|null $secure = null)

Deletes a cookie.

self
deleteHeader(string $name)

No description

Details

at line 153
IResponse setCode(int $code, string|null $reason = null)

Sets HTTP response code.

Parameters

int $code
string|null $reason

Return Value

IResponse

at line 158
int getCode()

Returns HTTP response code.

Return Value

int

at line 163
IResponse setHeader(string $name, string $value)

Sends a HTTP header and replaces a previous one.

Parameters

string $name
string $value

Return Value

IResponse

at line 168
IResponse addHeader(string $name, string $value)

Adds HTTP header.

Parameters

string $name
string $value

Return Value

IResponse

at line 173
IResponse setContentType(string $type, string|null $charset = null)

Sends a Content-type HTTP header.

Parameters

string $type
string|null $charset

Return Value

IResponse

at line 178
void redirect(string $url, int $code = self::S302_FOUND)

Redirects to a new URL.

Parameters

string $url
int $code

Return Value

void

at line 183
IResponse setExpiration(string|null $expire)

Sets the time (like '20 minutes') before a page cached on a browser expires, null means "must-revalidate".

Parameters

string|null $expire

Return Value

IResponse

at line 188
bool isSent()

Checks if headers have been sent.

Return Value

bool

at line 193
string|null getHeader(string $header)

Returns value of an HTTP header.

Parameters

string $header

Return Value

string|null

at line 198
array getHeaders()

Returns a associative array of headers to sent.

Return Value

array

at line 204
IResponse setCookie(string $name, string $value, string|int|DateTimeInterface $expire, string|null $path = null, string|null $domain = null, bool|null $secure = null, bool|null $httpOnly = null)

Sends a cookie.

Parameters

string $name
string $value
string|int|DateTimeInterface $expire

time, value null means "until the browser session ends"

string|null $path
string|null $domain
bool|null $secure
bool|null $httpOnly

Return Value

IResponse

at line 217
deleteCookie(string $name, string|null $path = null, string|null $domain = null, bool|null $secure = null)

Deletes a cookie.

Parameters

string $name
string|null $path
string|null $domain
bool|null $secure

at line 17
self deleteHeader(string $name)

No description

Parameters

string $name

Return Value

self