Enum HttpStatusCode
- All Implemented Interfaces:
Serializable, Comparable<HttpStatusCode>
Enum of standard HTTP status codes as defined by
IANA HTTP Status Code Registry.
Each constant carries its numeric code, a human-readable
reason phrase, and a HttpStatusCode.Family classification
(1xx informational, 2xx success, 3xx redirection, 4xx client error, 5xx server error).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe available HTTP status code families. -
Enum Constant Summary
Enum ConstantsEnum ConstantDescription202 Accepted — the request was accepted for processing but is not complete.502 Bad Gateway — a gateway or proxy received an invalid upstream response.400 Bad Request — the server cannot process the malformed request.409 Conflict — the request conflicts with the current resource state.201 Created — the request succeeded and created a new resource.417 Expectation Failed — the server cannot meet the Expect request-header expectation.403 Forbidden — the server understood the request but refuses to authorize it.302 Found — the resource is temporarily available under a different URI.504 Gateway Timeout — a gateway or proxy did not receive a timely upstream response.410 Gone — the resource is no longer available and no forwarding address is known.505 HTTP Version Not Supported — the server does not support the request HTTP version.500 Internal Server Error — the server encountered an unexpected condition.411 Length Required — the request requires a valid Content-Length header.405 Method Not Allowed — the request method is not supported for the resource.301 Moved Permanently — the resource has been assigned a new permanent URI.511 Network Authentication Required — the client must authenticate to gain network access.204 No Content — the request succeeded and there is no response body.406 Not Acceptable — no response representation matches the request headers.404 Not Found — the requested resource could not be found.501 Not Implemented — the server does not support the required functionality.304 Not Modified — the cached representation can be reused.200 OK — the request succeeded.206 Partial Content — the response contains the requested byte range.402 Payment Required — the status code is reserved for future use.412 Precondition Failed — a request precondition evaluated to false.428 Precondition Required — the origin server requires the request to be conditional.407 Proxy Authentication Required — authentication with a proxy is required.413 Request Entity Too Large — the request payload is larger than the server will process.431 Request Header Fields Too Large — the request header fields are too large.408 Request Timeout — the server timed out waiting for the request.414 Request-URI Too Long — the request URI is longer than the server will process.416 Requested Range Not Satisfiable — the requested range cannot be served.205 Reset Content — the request succeeded and the client should reset the document view.303 See Other — the response to the request can be found under another URI.503 Service Unavailable — the server is temporarily unable to handle the request.307 Temporary Redirect — the request should be repeated at another URI using the same method.429 Too Many Requests — the user has sent too many requests in a given time.401 Unauthorized — authentication is required or has failed.415 Unsupported Media Type — the request payload format is not supported.305 Use Proxy — the resource must be accessed through a proxy. -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpStatusCodefromStatusCode(int statusCode) Returns the enum constant for the given status code.Returns the status code family.Returns the reason phrase.intReturns the numeric status code.toString()Returns the reason phrase.static HttpStatusCodeReturns the enum constant of this type with the specified name.static HttpStatusCode[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
OK
200 OK — the request succeeded. -
CREATED
201 Created — the request succeeded and created a new resource. -
ACCEPTED
202 Accepted — the request was accepted for processing but is not complete. -
NO_CONTENT
204 No Content — the request succeeded and there is no response body. -
RESET_CONTENT
205 Reset Content — the request succeeded and the client should reset the document view. -
PARTIAL_CONTENT
206 Partial Content — the response contains the requested byte range. -
MOVED_PERMANENTLY
301 Moved Permanently — the resource has been assigned a new permanent URI. -
FOUND
302 Found — the resource is temporarily available under a different URI. -
SEE_OTHER
303 See Other — the response to the request can be found under another URI. -
NOT_MODIFIED
304 Not Modified — the cached representation can be reused. -
USE_PROXY
305 Use Proxy — the resource must be accessed through a proxy. -
TEMPORARY_REDIRECT
307 Temporary Redirect — the request should be repeated at another URI using the same method. -
BAD_REQUEST
400 Bad Request — the server cannot process the malformed request. -
UNAUTHORIZED
401 Unauthorized — authentication is required or has failed. -
PAYMENT_REQUIRED
402 Payment Required — the status code is reserved for future use. -
FORBIDDEN
403 Forbidden — the server understood the request but refuses to authorize it. -
NOT_FOUND
404 Not Found — the requested resource could not be found. -
METHOD_NOT_ALLOWED
405 Method Not Allowed — the request method is not supported for the resource. -
NOT_ACCEPTABLE
406 Not Acceptable — no response representation matches the request headers. -
PROXY_AUTHENTICATION_REQUIRED
407 Proxy Authentication Required — authentication with a proxy is required. -
REQUEST_TIMEOUT
408 Request Timeout — the server timed out waiting for the request. -
CONFLICT
409 Conflict — the request conflicts with the current resource state. -
GONE
410 Gone — the resource is no longer available and no forwarding address is known. -
LENGTH_REQUIRED
411 Length Required — the request requires a valid Content-Length header. -
PRECONDITION_FAILED
412 Precondition Failed — a request precondition evaluated to false. -
REQUEST_ENTITY_TOO_LARGE
413 Request Entity Too Large — the request payload is larger than the server will process. -
REQUEST_URI_TOO_LONG
414 Request-URI Too Long — the request URI is longer than the server will process. -
UNSUPPORTED_MEDIA_TYPE
415 Unsupported Media Type — the request payload format is not supported. -
REQUESTED_RANGE_NOT_SATISFIABLE
416 Requested Range Not Satisfiable — the requested range cannot be served. -
EXPECTATION_FAILED
417 Expectation Failed — the server cannot meet the Expect request-header expectation. -
PRECONDITION_REQUIRED
428 Precondition Required — the origin server requires the request to be conditional. -
TOO_MANY_REQUESTS
429 Too Many Requests — the user has sent too many requests in a given time. -
REQUEST_HEADER_FIELDS_TOO_LARGE
431 Request Header Fields Too Large — the request header fields are too large. -
INTERNAL_SERVER_ERROR
500 Internal Server Error — the server encountered an unexpected condition. -
NOT_IMPLEMENTED
501 Not Implemented — the server does not support the required functionality. -
BAD_GATEWAY
502 Bad Gateway — a gateway or proxy received an invalid upstream response. -
SERVICE_UNAVAILABLE
503 Service Unavailable — the server is temporarily unable to handle the request. -
GATEWAY_TIMEOUT
504 Gateway Timeout — a gateway or proxy did not receive a timely upstream response. -
HTTP_VERSION_NOT_SUPPORTED
505 HTTP Version Not Supported — the server does not support the request HTTP version. -
NETWORK_AUTHENTICATION_REQUIRED
511 Network Authentication Required — the client must authenticate to gain network access.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
getFamily
Returns the status code family.- Returns:
- the status code family
-
getStatusCode
public int getStatusCode()Returns the numeric status code.- Returns:
- the numeric status code
-
getReasonPhrase
-
toString
Returns the reason phrase.- Overrides:
toStringin classEnum<HttpStatusCode>- Returns:
- the reason phrase
-
fromStatusCode
Returns the enum constant for the given status code.- Parameters:
statusCode- the status code- Returns:
- the matching enum constant, or
nullif none matches
-