StatusCode

Enum
backed by int

Enum StatusCode.

Description

Defines HTTP status codes in accordance with the IETF RFC 9110 and related specifications. This enum provides a structured representation of common HTTP response codes, grouped by their respective categories:

  • Informational (1xx)
  • Successful (2xx)
  • Redirection (3xx)
  • Client Errors (4xx)
  • Server Errors (5xx)

All status codes MUST adhere to the official HTTP specification and SHALL be used consistently within HTTP responses.

Table of Contents

Cases

Methods

getCategory()

Returns the category of the status code.

 : string
getCode()

Returns the numeric HTTP status code.

 : int
getReasonPhrase()

Returns a human-readable description of the status code.

 : string
isClientError()

Returns true if the status code indicates a client error (4xx).

 : bool
isError()

Returns true if the status code indicates any type of error (client or server).

 : bool
isInformational()

Returns true if the status code is informational (1xx).

 : bool
isRedirection()

Returns true if the status code indicates redirection (3xx).

 : bool
isServerError()

Returns true if the status code indicates a server error (5xx).

 : bool
isSuccess()

Returns true if the status code indicates success (2xx).

 : bool
Cases

Cases

Methods

getCategory()

Public

Returns the category of the status code.

public getCategory() : string

Description

Categories are based on the first digit of the status code:

  • 1: Informational
  • 2: Success
  • 3: Redirection
  • 4: Client Error
  • 5: Server Error
Return values
string

getCode()

Public

Returns the numeric HTTP status code.

public getCode() : int
Return values
int

Description

the numeric status code as defined by the HTTP specification

getReasonPhrase()

Public

Returns a human-readable description of the status code.

public getReasonPhrase() : string

Description

The description is derived from the enum name, replacing underscores with spaces and capitalizing each word.

Return values
string

Description

the reason phrase corresponding to the status code

isClientError()

Public

Returns true if the status code indicates a client error (4xx).

public isClientError() : bool
Return values
bool

isError()

Public

Returns true if the status code indicates any type of error (client or server).

public isError() : bool
Return values
bool

isInformational()

Public

Returns true if the status code is informational (1xx).

public isInformational() : bool
Return values
bool

isRedirection()

Public

Returns true if the status code indicates redirection (3xx).

public isRedirection() : bool
Return values
bool

isServerError()

Public

Returns true if the status code indicates a server error (5xx).

public isServerError() : bool
Return values
bool

isSuccess()

Public

Returns true if the status code indicates success (2xx).

public isSuccess() : bool
Return values
bool