interface IResponse

HTTP response contract for setting status code, headers, cookies, and redirects.

Constants

S100_Continue

HTTP 1.1 response code

S101_SwitchingProtocols

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_NonAuthoritativeInformation

HTTP 1.1 response code

S204_NoContent

HTTP 1.1 response code

S205_ResetContent

HTTP 1.1 response code

S206_PartialContent

HTTP 1.1 response code

S207_MultiStatus

HTTP 1.1 response code

S208_AlreadyReported

HTTP 1.1 response code

S226_ImUsed

HTTP 1.1 response code

S300_MultipleChoices

HTTP 1.1 response code

S301_MovedPermanently

HTTP 1.1 response code

S302_Found

HTTP 1.1 response code

S303_PostGet

HTTP 1.1 response code

S304_NotModified

HTTP 1.1 response code

S305_UseProxy

HTTP 1.1 response code

S307_TemporaryRedirect

HTTP 1.1 response code

S308_PermanentRedirect

HTTP 1.1 response code

S400_BadRequest

HTTP 1.1 response code

S401_Unauthorized

HTTP 1.1 response code

S402_PaymentRequired

HTTP 1.1 response code

S403_Forbidden

HTTP 1.1 response code

S404_NotFound

HTTP 1.1 response code

S405_MethodNotAllowed

HTTP 1.1 response code

S406_NotAcceptable

HTTP 1.1 response code

S407_ProxyAuthenticationRequired

HTTP 1.1 response code

S408_RequestTimeout

HTTP 1.1 response code

S409_Conflict

HTTP 1.1 response code

S410_Gone

HTTP 1.1 response code

S411_LengthRequired

HTTP 1.1 response code

S412_PreconditionFailed

HTTP 1.1 response code

S413_RequestEntityTooLarge

HTTP 1.1 response code

S414_RequestUriTooLong

HTTP 1.1 response code

S415_UnsupportedMediaType

HTTP 1.1 response code

S416_RequestedRangeNotSatisfiable

HTTP 1.1 response code

S417_ExpectationFailed

HTTP 1.1 response code

S421_MisdirectedRequest

HTTP 1.1 response code

S422_UnprocessableEntity

HTTP 1.1 response code

S423_Locked

HTTP 1.1 response code

S424_FailedDependency

HTTP 1.1 response code

S426_UpgradeRequired

HTTP 1.1 response code

S428_PreconditionRequired

HTTP 1.1 response code

S429_TooManyRequests

HTTP 1.1 response code

S431_RequestHeaderFieldsTooLarge

HTTP 1.1 response code

S451_UnavailableForLegalReasons

HTTP 1.1 response code

S500_InternalServerError

HTTP 1.1 response code

S501_NotImplemented

HTTP 1.1 response code

S502_BadGateway

HTTP 1.1 response code

S503_ServiceUnavailable

HTTP 1.1 response code

S504_GatewayTimeout

HTTP 1.1 response code

S505_HttpVersionNotSupported

HTTP 1.1 response code

S506_VariantAlsoNegotiates

HTTP 1.1 response code

S507_InsufficientStorage

HTTP 1.1 response code

S508_LoopDetected

HTTP 1.1 response code

S510_NotExtended

HTTP 1.1 response code

S511_NetworkAuthenticationRequired

HTTP 1.1 response code

ReasonPhrases

deprecated SameSiteLax

deprecated SameSiteStrict

deprecated SameSiteNone

REASON_PHRASES

SAME_SITE_LAX

SAME_SITE_STRICT

SAME_SITE_NONE

S100_CONTINUE

S101_SWITCHING_PROTOCOLS

S102_PROCESSING

S201_CREATED

S202_ACCEPTED

S203_NON_AUTHORITATIVE_INFORMATION

S204_NO_CONTENT

S205_RESET_CONTENT

S206_PARTIAL_CONTENT

S207_MULTI_STATUS

S208_ALREADY_REPORTED

S226_IM_USED

S300_MULTIPLE_CHOICES

S301_MOVED_PERMANENTLY

S302_FOUND

S303_SEE_OTHER

S303_POST_GET

S304_NOT_MODIFIED

S305_USE_PROXY

S307_TEMPORARY_REDIRECT

S308_PERMANENT_REDIRECT

S400_BAD_REQUEST

S401_UNAUTHORIZED

S402_PAYMENT_REQUIRED

S403_FORBIDDEN

S404_NOT_FOUND

S405_METHOD_NOT_ALLOWED

S406_NOT_ACCEPTABLE

S407_PROXY_AUTHENTICATION_REQUIRED

S408_REQUEST_TIMEOUT

S409_CONFLICT

S410_GONE

S411_LENGTH_REQUIRED

S412_PRECONDITION_FAILED

S413_REQUEST_ENTITY_TOO_LARGE

S414_REQUEST_URI_TOO_LONG

S415_UNSUPPORTED_MEDIA_TYPE

S416_REQUESTED_RANGE_NOT_SATISFIABLE

S417_EXPECTATION_FAILED

S421_MISDIRECTED_REQUEST

S422_UNPROCESSABLE_ENTITY

S423_LOCKED

S424_FAILED_DEPENDENCY

S426_UPGRADE_REQUIRED

S428_PRECONDITION_REQUIRED

S429_TOO_MANY_REQUESTS

S431_REQUEST_HEADER_FIELDS_TOO_LARGE

S451_UNAVAILABLE_FOR_LEGAL_REASONS

S500_INTERNAL_SERVER_ERROR

S501_NOT_IMPLEMENTED

S502_BAD_GATEWAY

S503_SERVICE_UNAVAILABLE

S504_GATEWAY_TIMEOUT

S505_HTTP_VERSION_NOT_SUPPORTED

S506_VARIANT_ALSO_NEGOTIATES

S507_INSUFFICIENT_STORAGE

S508_LOOP_DETECTED

S510_NOT_EXTENDED

S511_NETWORK_AUTHENTICATION_REQUIRED

Methods

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

Sets HTTP response code.

int
getCode()

Returns HTTP response code.

setHeader(string $name, string $value)

Sends an HTTP header, replacing any previously sent header with the same name.

addHeader(string $name, string $value)

Adds an HTTP header without replacing a previously sent header with the same name.

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 Cache-Control and Expires headers. Pass a time string (e.g. '20 minutes') to enable caching, or null to disable it.

bool
isSent()

Checks whether HTTP headers have already been sent.

string|null
getHeader(string $header)

Returns the value of a sent HTTP header, or null if it does not exist.

array
getHeaders()

Returns all sent HTTP headers as an associative array.

setCookie(string $name, string $value, string|int|DateTimeInterface|null $expire, string|null $path = null, string|null $domain = null, bool $secure = false, bool $httpOnly = true, SameSite $sameSite = SameSite::Lax, bool $partitioned = false)

Sends a cookie.

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

Deletes a cookie.

self
deleteHeader(string $name)

No description

Details

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

Sets HTTP response code.

Parameters

int $code
string|null $reason

Return Value

IResponse

at line 344
int getCode()

Returns HTTP response code.

Return Value

int

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

Sends an HTTP header, replacing any previously sent header with the same name.

Parameters

string $name
string $value

Return Value

IResponse

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

Adds an HTTP header without replacing a previously sent header with the same name.

Parameters

string $name
string $value

Return Value

IResponse

at line 359
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 364
void redirect(string $url, int $code = self::S302_Found)

Redirects to a new URL.

Parameters

string $url
int $code

Return Value

void

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

Sets the Cache-Control and Expires headers. Pass a time string (e.g. '20 minutes') to enable caching, or null to disable it.

Parameters

string|null $expire

Return Value

IResponse

at line 375
bool isSent()

Checks whether HTTP headers have already been sent.

Return Value

bool

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

Returns the value of a sent HTTP header, or null if it does not exist.

Parameters

string $header

Return Value

string|null

at line 386
array getHeaders()

Returns all sent HTTP headers as an associative array.

Return Value

array

at line 391
IResponse setCookie(string $name, string $value, string|int|DateTimeInterface|null $expire, string|null $path = null, string|null $domain = null, bool $secure = false, bool $httpOnly = true, SameSite $sameSite = SameSite::Lax, bool $partitioned = false)

Sends a cookie.

Parameters

string $name
string $value
string|int|DateTimeInterface|null $expire
string|null $path
string|null $domain
bool $secure
bool $httpOnly
SameSite $sameSite
bool $partitioned

Return Value

IResponse

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

Deletes a cookie.

Parameters

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

Return Value

void

at line 15
self deleteHeader(string $name)

No description

Parameters

string $name

Return Value

self