HttpStatus enum

Inheritance

Constructors

HttpStatus(int code, String message)
const

Values

ok → const HttpStatus

The request has succeeded. The meaning of a success varies depending on the HTTP method:

GET: The resource has been fetched and is transmitted in the message body. HEAD: The entity headers are in the message body. POST: The resource describing the result of the action is transmitted in the message body.

TRACE: The message body contains the request message as received by the server

https://tools.ietf.org/html/rfc7231#section-6.3.1

const HttpStatus(200, 'OK')
created → const HttpStatus

The request has succeeded and a new resource has been created as a result of it. This is typically the response sent after a PUT request.

https://tools.ietf.org/html/rfc7231#section-6.3.2

const HttpStatus(201, 'Created')
accepted → const HttpStatus

The request has been received but not yet acted upon. It is noncommittal, since there is no way in HTTP to later send an asynchronous response indicating the outcome of the request.

It is intended for cases where another process or server handles t he request, or for batch processing.

https://tools.ietf.org/html/rfc7231#section-6.3.3

const HttpStatus(202, 'Accepted')
noContent → const HttpStatus

There is no content to send for this request, but the headers may be useful. The user-agent may update its cached headers for this resource with the new ones.

https://tools.ietf.org/html/rfc7231#section-6.3.5

const HttpStatus(204, 'No Content')
badRequest → const HttpStatus

This response means that server could not understand the request due to invalid syntax.

https://tools.ietf.org/html/rfc7231#section-6.5.1

const HttpStatus(400, 'Bad Request')
unauthorized → const HttpStatus

Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response.

https://tools.ietf.org/html/rfc7235#section-3.1

const HttpStatus(401, 'Unauthorized')
forbidden → const HttpStatus

The client does not have access rights to the content, i.e. they are unauthorized, so server is rejecting to give proper response. Unlike 401, the client's identity is known to the server.

https://tools.ietf.org/html/rfc7231#section-6.5.3

const HttpStatus(403, 'Forbidden')
notFound → const HttpStatus

The server can not find requested resource.

In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist.

Servers may also send this response instead of 403 to hide the existence of a resource from an unauthorized client.

This response code is probably the most famous one due to its frequent occurrence on the web.

https://tools.ietf.org/html/rfc7231#section-6.5.4

const HttpStatus(404, 'Not Found')
gone → const HttpStatus

This response would be sent when the requested content has been permanently deleted from server, with no forwarding address.

Clients are expected to remove their caches and links to the resource.

The HTTP specification intends this status code to be used for "limited-time, promotional services".

APIs should not feel compelled to indicate resources that have been deleted with this status code.

https://tools.ietf.org/html/rfc7231#section-6.5.9

const HttpStatus(410, 'Gone')
unprocessableEntity → const HttpStatus

The request was well-formed but was unable to be followed due to semantic errors.

https://tools.ietf.org/html/rfc2518#section-10.3

const HttpStatus(422, 'Unprocessable Entity')
tooManyRequests → const HttpStatus

The user has sent too many requests in a given amount of time ("rate limiting").

https://tools.ietf.org/html/rfc6585#section-4

const HttpStatus(429, 'Too Many Requests')
internalServerError → const HttpStatus

The server encountered an unexpected condition that prevented it from fulfilling the request.

https://tools.ietf.org/html/rfc7231#section-6.6.1

const HttpStatus(500, 'Internal Server Error')
notImplemented → const HttpStatus

The request method is not supported by the server and cannot be handled.

The only methods that servers are required to support (and therefore that must not return this code) are GET and HEAD.

https://tools.ietf.org/html/rfc7231#section-6.6.2

const HttpStatus(501, 'Not Implemented')
badGateway → const HttpStatus

This error response means that the server, while working as a gateway to get a response needed to handle the request, got an invalid response.

https://tools.ietf.org/html/rfc7231#section-6.6.3

const HttpStatus(502, 'Bad Gateway')
serviceUnavailable → const HttpStatus

The server is not ready to handle the request.

Common causes are a server that is down for maintenance or that is overloaded. Note that together with this response, a user-friendly page explaining the problem should be sent.

This responses should be used for temporary conditions and the Retry-After: HTTP header should, if possible, contain the estimated time before the recovery of the service.

The webmaster must also take care about the caching-related headers that are sent along with this response, as these temporary condition responses should usually not be cached.

https://tools.ietf.org/html/rfc7231#section-6.6.4

const HttpStatus(503, 'Service Unavailable')

Properties

code int
The http status code.
final
hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
message String
The http status message.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

equalsByCode(int code) bool
Returns true if this code equals to passed code, otherwise false.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

valueOf(int code) HttpStatus
Returns the http status of code.

Constants

values → const List<HttpStatus>
A constant List of the values in this enum, in order of their declaration.