new $k.HttpResponse()
A HTTP response
Extends
Members
-
static$k.HttpResponse.BAD_REQUEST
-
Status code 400 Bad Request
-
static$k.HttpResponse.INTERNAL_SERVER_ERROR
-
Status code 500 Internal Server Error
-
static$k.HttpResponse.NOT_FOUND
-
Status code 404 Not Found
-
static$k.HttpResponse.NOT_MODIFIED
-
Status code 304 Not Modified
-
static$k.HttpResponse.OK
-
Status code 200 OK
-
static$k.HttpResponse.UNAUTHORIZED
-
Status code 401 Unauthorized
Methods
code() : number
Returns the status code of the response
Returns:
Type | Description |
---|---|
number |
isSuccess() : boolean
Returns true if the code indicates a successful response (2xx), false otherwise
Returns:
Type | Description |
---|---|
boolean |
setCode(code)
Set the status code of the response
Name | Type | Description |
---|---|---|
code |
number |
Throws:
Type | Description |
---|---|
$k.exception.InvalidValue | If the code is not a valid HTTP status code |
setCodeBadRequest()
Set the status code of the response to 400 (Bad request). Equivalent to setCode($k.HttpResponse.BAD_REQUEST)
setCodeNotFound()
Set the status code of the response to 404 (Not found). Equivalent to setCode($k.HttpResponse.NOT_FOUND)
setCodeNotModified()
Set the status code of the response to 304 (Not Modified). Equivalent to setCode($k.HttpResponse.NOT_MODIFIED)
setCodeOk()
Set the status code of the response to 200 (Ok). Equivalent to setCode($k.HttpResponse.OK)
setCodeUnauthorized()
Set the status code of the response to 401 (Unauthorized). Equivalent to setCode($k.HttpResponse.UNAUTHORIZED)
setCookie(cookie)
Add the cookie to the response, instructing the client to set the cookie
Name | Type | Description |
---|---|---|
cookie |
$k.NewCookie |
The new cookie |
Throws:
Type | Description |
---|---|
$k.exception.TypeError | If the cookie is not a valid new cookie |