Class $k.HttpResponse

A HTTP response

Class Summary
Constructor Attributes Constructor Name and Description
 

Method Summary

Class Detail

$k.HttpResponse()

Field Detail

<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

Method Detail

  • {number} code()
    Returns the status code of the response
    Returns:
    {number}
  • setCode(code)
    Set the status code of the response
    Parameters:
    {number} code
    Throws:
    {$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
    Parameters:
    {$k.NewCookie} cookie
    The new cookie
    Throws:
    {$k.exception.TypeError}
    If the cookie is not a valid new cookie