public final class Status extends Object
HTTP status codes are extensible. HTTP clients are not required to understand the meaning of all registered status codes, though such understanding is obviously desirable. However, a client MUST understand the class of any status code, as indicated by the first digit, and treat an unrecognized status code as being equivalent to the x00 status code of that class, with the exception that a recipient MUST NOT cache a response with an unrecognized status code.
For example, if an unrecognized status code of 471 is received by a client, the client can assume that there was something wrong with its request and treat the response as if it had received a 400 (Bad Request) status code. The response message will usually contain a representation that explains the status.
The first digit of the status-code defines the class of response. The last two digits do not have any categorization role. There are five values for the first digit:
The reason phrases are only recommendations they can be replaced by local equivalents without affecting the protocol.
Modifier and Type | Class and Description |
---|---|
static class |
Status.Family
The first digit of the status-code defines the class of response.
|
Modifier and Type | Field and Description |
---|---|
static Status |
ACCEPTED
The 202 (Accepted) status code indicates that the request has been
accepted for processing, but the processing has not been completed.
|
static Status |
BAD_GATEWAY
The 502 (Bad Gateway) status code indicates that the server, while
acting as a gateway or proxy, received an invalid response from an
inbound server it accessed while attempting to fulfill the request.
|
static Status |
BAD_REQUEST
The 400 (Bad Request) status code indicates that the server cannot or
will not process the request due to something that is perceived to be
a client error (e.g., malformed request syntax, invalid request
message framing, or deceptive request routing).
|
static Status |
CONFLICT
The 409 (Conflict) status code indicates that the request could not
be completed due to a conflict with the current state of the target
resource.
|
static Status |
CONTINUE
The 100 (Continue) status code indicates that the initial part of a
request has been received and has not yet been rejected by the
server.
|
static Status |
CREATED
The 201 (Created) status code indicates that the request has been
fulfilled and has resulted in one or more new resources being
created.
|
static Status |
EXPECTATION_FAILED
The 417 (Expectation Failed) status code indicates that the
expectation given in the request's Expect header field
(Section 5.1.1) could not be met by at least one of the inbound
servers.
|
static Status |
FORBIDDEN
The 403 (Forbidden) status code indicates that the server understood
the request but refuses to authorize it.
|
static Status |
FOUND
The 302 (Found) status code indicates that the target resource
resides temporarily under a different URI.
|
static Status |
GATEWAY_TIMEOUT
The 504 (Gateway Timeout) status code indicates that the server,
while acting as a gateway or proxy, did not receive a timely response
from an upstream server it needed to access in order to complete the
request.
|
static Status |
GONE
The 410 (Gone) status code indicates that access to the target
resource is no longer available at the origin server and that this
condition is likely to be permanent.
|
static Status |
HTTP_VERSION_NOT_SUPPORTED
The 505 (HTTP Version Not Supported) status code indicates that the
server does not support, or refuses to support, the major version of
HTTP that was used in the request message.
|
static Status |
INTERNAL_SERVER_ERROR
The 500 (Internal Server Error) status code indicates that the server
encountered an unexpected condition that prevented it from fulfilling
the request.
|
static Status |
LENGTH_REQUIRED
The 411 (Length Required) status code indicates that the server
refuses to accept the request without a defined Content-Length
(Section 3.3.2 of [RFC7230]).
|
static Status |
METHOD_NOT_ALLOWED
The 405 (Method Not Allowed) status code indicates that the method
received in the request-line is known by the origin server but not
supported by the target resource.
|
static Status |
MOVED_PERMANENTLY
The 301 (Moved Permanently) status code indicates that the target
resource has been assigned a new permanent URI and any future
references to this resource ought to use one of the enclosed URIs.
|
static Status |
MULTIPLE_CHOICES
The 300 (Multiple Choices) status code indicates that the target
resource has more than one representation, each with its own more
specific identifier, and information about the alternatives is being
provided so that the user (or user agent) can select a preferred
representation by redirecting its request to one or more of those
identifiers.
|
static Status |
NO_CONTENT
The 204 (No Content) status code indicates that the server has
successfully fulfilled the request and that there is no additional
content to send in the response payload body.
|
static Status |
NON_AUTHORITATIVE_INFO
The 203 (Non-Authoritative Information) status code indicates that
the request was successful but the enclosed payload has been modified
from that of the origin server's 200 (OK) response by a transforming
proxy (Section 5.7.2 of [RFC7230]).
|
static Status |
NOT_ACCEPTABLE
The 406 (Not Acceptable) status code indicates that the target
resource does not have a current representation that would be
acceptable to the user agent, according to the proactive negotiation
header fields received in the request (Section 5.3), and the server
is unwilling to supply a default representation.
|
static Status |
NOT_FOUND
The 404 (Not Found) status code indicates that the origin server did
not find a current representation for the target resource or is not
willing to disclose that one exists.
|
static Status |
NOT_IMPLEMENTED
The 501 (Not Implemented) status code indicates that the server does
not support the functionality required to fulfill the request.
|
static Status |
OK
The 200 (OK) status code indicates that the request has succeeded.
|
static Status |
PAYLOAD_TOO_LARGE
The 413 (Payload Too Large) status code indicates that the server is
refusing to process a request because the request payload is larger
than the server is willing or able to process.
|
static Status |
PAYMENT_REQUIRED
The 402 (Payment Required) status code is reserved for future use.
|
static Status |
PROXY_AUTHENTICATION_REQUIRED
The 407 (Proxy Authentication Required) status code is similar to 401
(Unauthorized), but it indicates that the client needs to
authenticate itself in order to use a proxy.
|
static Status |
REQUEST_TIMEOUT
The 408 (Request Timeout) status code indicates that the server did
not receive a complete request message within the time that it was
prepared to wait.
|
static Status |
RESET_CONTENT
The 205 (Reset Content) status code indicates that the server has
fulfilled the request and desires that the user agent reset the
"document view", which caused the request to be sent, to its original
state as received from the origin server.
|
static Status |
SEE_OTHER
The 303 (See Other) status code indicates that the server is
redirecting the user agent to a different resource, as indicated by a
URI in the Location header field, which is intended to provide an
indirect response to the original request.
|
static Status |
SERVICE_UNAVAILABLE
The 503 (Service Unavailable) status code indicates that the server
is currently unable to handle the request due to a temporary overload
or scheduled maintenance, which will likely be alleviated after some
delay.
|
static Status |
SWITCHING_PROTOCOLS
The 101 (Switching Protocols) status code indicates that the server
understands and is willing to comply with the client's request, via
the Upgrade header field (Section 6.7 of [RFC7230]), for a change in
the application protocol being used on this connection.
|
static Status |
TEAPOT
Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot".
|
static Status |
TEMPORARY_REDIRECT
The 307 (Temporary Redirect) status code indicates that the target
resource resides temporarily under a different URI and the user agent
MUST NOT change the request method if it performs an automatic
redirection to that URI.
|
static Status |
TOO_MANY_REQUESTS
The 429 status code indicates that the user has sent too many requests in a given amount of time
("rate limiting").
|
static Status |
UNAUTHORIZED
The request requires user authentication.
|
static Status |
UNSUPPORTED_MEDIA_TYPE
The 415 (Unsupported Media Type) status code indicates that the
origin server is refusing to service the request because the payload
is in a format not supported by this method on the target resource.
|
static Status |
UNUSED
The 306 status code was defined in a previous version of this
specification, is no longer used, and the code is reserved.
|
static Status |
UPGRADE_REQUIRED
The 426 (Upgrade Required) status code indicates that the server
refuses to perform the request using the current protocol but might
be willing to do so after the client upgrades to a different
protocol.
|
static Status |
URI_TOO_LONG
The 414 (URI Too Long) status code indicates that the server is
refusing to service the request because the request-target (Section
5.3 of [RFC7230]) is longer than the server is willing to interpret.
|
static Status |
USE_PROXY
The 305 (Use Proxy) status code was defined in a previous version of
this specification and is now deprecated (Appendix B).
|
Modifier and Type | Method and Description |
---|---|
int |
getCode()
Returns the three-digit integer code giving the result of the attempt to understand and satisfy the request.
|
Status.Family |
getFamily()
Returns the class of response of this status code.
|
String |
getReasonPhrase()
Returns the reason phrase associated with the status code.
|
boolean |
isClientError()
Is the family of this status a
Status.Family.CLIENT_ERROR one ? |
boolean |
isInformational()
Is the family of this status a
Status.Family.INFORMATIONAL one ? |
boolean |
isRedirection()
Is the family of this status a
Status.Family.REDIRECTION one ? |
boolean |
isServerError()
Is the family of this status a
Status.Family.SERVER_ERROR one ? |
boolean |
isSuccessful()
Is the family of this status a
Status.Family.SUCCESSFUL one ? |
String |
toString() |
static Status |
valueOf(int code)
Get a
Status from the given integer. |
static Status |
valueOf(int code,
String reason)
Get a
Status from the given integer. |
public static final Status CONTINUE
public static final Status SWITCHING_PROTOCOLS
public static final Status OK
public static final Status CREATED
public static final Status ACCEPTED
public static final Status NON_AUTHORITATIVE_INFO
public static final Status NO_CONTENT
public static final Status RESET_CONTENT
public static final Status MULTIPLE_CHOICES
public static final Status MOVED_PERMANENTLY
public static final Status FOUND
public static final Status SEE_OTHER
public static final Status USE_PROXY
public static final Status UNUSED
public static final Status TEMPORARY_REDIRECT
public static final Status BAD_REQUEST
public static final Status UNAUTHORIZED
public static final Status PAYMENT_REQUIRED
public static final Status FORBIDDEN
public static final Status NOT_FOUND
public static final Status METHOD_NOT_ALLOWED
public static final Status NOT_ACCEPTABLE
public static final Status PROXY_AUTHENTICATION_REQUIRED
public static final Status REQUEST_TIMEOUT
public static final Status CONFLICT
public static final Status GONE
public static final Status LENGTH_REQUIRED
public static final Status PAYLOAD_TOO_LARGE
public static final Status URI_TOO_LONG
public static final Status UNSUPPORTED_MEDIA_TYPE
public static final Status EXPECTATION_FAILED
public static final Status TEAPOT
public static final Status UPGRADE_REQUIRED
HTTP/1.1 426 Upgrade Required
Upgrade: HTTP/3.0
Connection: Upgrade
Content-Length: 53
Content-Type: text/plain
This service requires use of the HTTP/3.0 protocol.public static final Status TOO_MANY_REQUESTS
HTTP/1.1 429 Too Many Requests
Content-Type: text/html
Retry-After: 3600
<html>
<head>
<title>Too Many Requests</title>
</head>
<body>
<h1>Too Many Requests</h1>
<p>I only allow 50 requests per hour to this Web site per logged in user. Try again soon.</p>
</body>
</html>
Note that this specification does not define how the origin server identifies the user, nor how
it counts requests. For example, an origin server that is limiting request rates can do so based upon counts of
requests on a per-resource basis, across the entire server, or even among a set of servers. Likewise, it might
identify the user by its authentication credentials, or a stateful cookie. Responses with the 429 status code
MUST NOT be stored by a cache.public static final Status INTERNAL_SERVER_ERROR
public static final Status NOT_IMPLEMENTED
public static final Status BAD_GATEWAY
public static final Status SERVICE_UNAVAILABLE
public static final Status GATEWAY_TIMEOUT
public static final Status HTTP_VERSION_NOT_SUPPORTED
public int getCode()
public String getReasonPhrase()
public Status.Family getFamily()
public boolean isInformational()
Status.Family.INFORMATIONAL
one ?Status.Family.INFORMATIONAL
one.public boolean isSuccessful()
Status.Family.SUCCESSFUL
one ?Status.Family.SUCCESSFUL
one.public boolean isRedirection()
Status.Family.REDIRECTION
one ?Status.Family.REDIRECTION
one.public boolean isClientError()
Status.Family.CLIENT_ERROR
one ?Status.Family.CLIENT_ERROR
one.public boolean isServerError()
Status.Family.SERVER_ERROR
one ?Status.Family.SERVER_ERROR
one.public static Status valueOf(int code)
Status
from the given integer.
First try to match a known (supported by this enum) status code, otherwise try to build a new one.code
- the three-digit integer code giving the result of the attempt to understand and satisfy the request.
It must be in the range 100 <= code < 1000
and not already used by another Status
,
otherwise an IllegalArgumentException
is thrown.Status
public static Status valueOf(int code, String reason)
Status
from the given integer.
First try to match a known (supported by this enum) status code, otherwise try to build a new one.code
- the three-digit integer code giving the result of the attempt to understand and satisfy the request.
It must be in the range 100 <= code < 1000
and not already used by another Status
,
otherwise an IllegalArgumentException
is thrown.reason
- the reason phrase to describe this Status
. It is purely informative.Status
Copyright © 2010-2018, ForgeRock All Rights Reserved.