/** Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*http://www.apache.org/licenses/LICENSE-2.0*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.*/
packageorg.springframework.http;/*** Enumeration of HTTP status codes.
*
*
The HTTP status code series can be retrieved via {@link#series()}.
*
*@authorArjen Poutsma
*@authorSebastien Deleuze
*@authorBrian Clozel
*@since3.0
*@seeHttpStatus.Series
*@seeHTTP Status Code Registry
*@seeList of HTTP status codes - Wikipedia*/
public enumHttpStatus {//1xx Informational
/*** {@code100 Continue}.
*@seeHTTP/1.1: Semantics and Content, section 6.2.1*/CONTINUE(100, "Continue"),/*** {@code101 Switching Protocols}.
*@seeHTTP/1.1: Semantics and Content, section 6.2.2*/SWITCHING_PROTOCOLS(101, "Switching Protocols"),/*** {@code102 Processing}.
*@seeWebDAV*/PROCESSING(102, "Processing"),/*** {@code103 Checkpoint}.
*@seeA proposal for supporting
* resumable POST/PUT HTTP requests in HTTP/1.0*/CHECKPOINT(103, "Checkpoint"),//2xx Success
/*** {@code200 OK}.
*@seeHTTP/1.1: Semantics and Content, section 6.3.1*/OK(200, "OK"),/*** {@code201 Created}.
*@seeHTTP/1.1: Semantics and Content, section 6.3.2*/CREATED(201, "Created"),/*** {@code202 Accepted}.
*@seeHTTP/1.1: Semantics and Content, section 6.3.3*/ACCEPTED(202, "Accepted"),/*** {@code203 Non-Authoritative Information}.
*@seeHTTP/1.1: Semantics and Content, section 6.3.4*/NON_AUTHORITATIVE_INFORMATION(203, "Non-Authoritative Information"),/*** {@code204 No Content}.
*@seeHTTP/1.1: Semantics and Content, section 6.3.5*/NO_CONTENT(204, "No Content"),/*** {@code205 Reset Content}.
*@seeHTTP/1.1: Semantics and Content, section 6.3.6*/RESET_CONTENT(205, "Reset Content"),/*** {@code206 Partial Content}.
*@seeHTTP/1.1: Range Requests, section 4.1*/PARTIAL_CONTENT(206, "Partial Content"),/*** {@code207 Multi-Status}.
*@seeWebDAV*/MULTI_STATUS(207, "Multi-Status"),/*** {@code208 Already Reported}.
*@seeWebDAV Binding Extensions*/ALREADY_REPORTED(208, "Already Reported"),/*** {@code226 IM Used}.
*@seeDelta encoding in HTTP*/IM_USED(226, "IM Used"),//3xx Redirection
/*** {@code300 Multiple Choices}.
*@seeHTTP/1.1: Semantics and Content, section 6.4.1*/MULTIPLE_CHOICES(300, "Multiple Choices"),/*** {@code301 Moved Permanently}.
*@seeHTTP/1.1: Semantics and Content, section 6.4.2*/MOVED_PERMANENTLY(301, "Moved Permanently"),/*** {@code302 Found}.
*@seeHTTP/1.1: Semantics and Content, section 6.4.3*/FOUND(302, "Found"),/*** {@code302 Moved Temporarily}.
*@deprecatedin favor of {@link#FOUND} which will be returned from {@codeHttpStatus.valueOf(302)}*/@Deprecated
MOVED_TEMPORARILY(302, "Moved Temporarily"),/*** {@code303 See Other}.
*@seeHTTP/1.1: Semantics and Content, section 6.4.4*/SEE_OTHER(303, "See Other"),/*** {@code304 Not Modified}.
*@seeHTTP/1.1: Conditional Requests, section 4.1*/NOT_MODIFIED(304, "Not Modified"),/*** {@code305 Use Proxy}.
*@seeHTTP/1.1: Semantics and Content, section 6.4.5
*@deprecateddue to security concerns regarding in-band configuration of a proxy*/@Deprecated
USE_PROXY(305, "Use Proxy"),/*** {@code307 Temporary Redirect}.
*@seeHTTP/1.1: Semantics and Content, section 6.4.7*/TEMPORARY_REDIRECT(307, "Temporary Redirect"),/*** {@code308 Permanent Redirect}.
*@seeRFC 7238*/PERMANENT_REDIRECT(308, "Permanent Redirect"),//--- 4xx Client Error ---
/*** {@code400 Bad Request}.
*@seeHTTP/1.1: Semantics and Content, section 6.5.1*/BAD_REQUEST(400, "Bad Request"),/*** {@code401 Unauthorized}.
*@seeHTTP/1.1: Authentication, section 3.1*/UNAUTHORIZED(401, "Unauthorized"),/*** {@code402 Payment Required}.
*@seeHTTP/1.1: Semantics and Content, section 6.5.2*/PAYMENT_REQUIRED(402, "Payment Required"),/*** {@code403 Forbidden}.
*@seeHTTP/1.1: Semantics and Content, section 6.5.3*/FORBIDDEN(403, "Forbidden"),/*** {@code404 Not Found}.
*@seeHTTP/1.1: Semantics and Content, section 6.5.4*/NOT_FOUND(404, "Not Found"),/*** {@code405 Method Not Allowed}.
*@seeHTTP/1.1: Semantics and Content, section 6.5.5*/METHOD_NOT_ALLOWED(405, "Method Not Allowed"),/*** {@code406 Not Acceptable}.
*@seeHTTP/1.1: Semantics and Content, section 6.5.6*/NOT_ACCEPTABLE(406, "Not Acceptable"),/*** {@code407 Proxy Authentication Required}.
*@seeHTTP/1.1: Authentication, section 3.2*/PROXY_AUTHENTICATION_REQUIRED(407, "Proxy Authentication Required"),/*** {@code408 Request Timeout}.
*@seeHTTP/1.1: Semantics and Content, section 6.5.7*/REQUEST_TIMEOUT(408, "Request Timeout"),/*** {@code409 Conflict}.
*@seeHTTP/1.1: Semantics and Content, section 6.5.8*/CONFLICT(409, "Conflict"),/*** {@code410 Gone}.
*@seeHTTP/1.1: Semantics and Content, section 6.5.9*/GONE(410, "Gone"),/*** {@code411 Length Required}.
*@seeHTTP/1.1: Semantics and Content, section 6.5.10*/LENGTH_REQUIRED(411, "Length Required"),/*** {@code412 Precondition failed}.
*@seeHTTP/1.1: Conditional Requests, section 4.2*/PRECONDITION_FAILED(412, "Precondition Failed"),/*** {@code413 Payload Too Large}.
*@since4.1
*@seeHTTP/1.1: Semantics and Content, section 6.5.11*/PAYLOAD_TOO_LARGE(413, "Payload Too Large"),/*** {@code413 Request Entity Too Large}.
*@seeHTTP/1.1, section 10.4.14
*@deprecatedin favor of {@link#PAYLOAD_TOO_LARGE} which will be returned from {@codeHttpStatus.valueOf(413)}*/@Deprecated
REQUEST_ENTITY_TOO_LARGE(413, "Request Entity Too Large"),/*** {@code414 URI Too Long}.
*@since4.1
*@seeHTTP/1.1: Semantics and Content, section 6.5.12*/URI_TOO_LONG(414, "URI Too Long"),/*** {@code414 Request-URI Too Long}.
*@seeHTTP/1.1, section 10.4.15
*@deprecatedin favor of {@link#URI_TOO_LONG} which will be returned from {@codeHttpStatus.valueOf(414)}*/@Deprecated
REQUEST_URI_TOO_LONG(414, "Request-URI Too Long"),/*** {@code415 Unsupported Media Type}.
*@seeHTTP/1.1: Semantics and Content, section 6.5.13*/UNSUPPORTED_MEDIA_TYPE(415, "Unsupported Media Type"),/*** {@code416 Requested Range Not Satisfiable}.
*@seeHTTP/1.1: Range Requests, section 4.4*/REQUESTED_RANGE_NOT_SATISFIABLE(416, "Requested range not satisfiable"),/*** {@code417 Expectation Failed}.
*@seeHTTP/1.1: Semantics and Content, section 6.5.14*/EXPECTATION_FAILED(417, "Expectation Failed"),/*** {@code418 I'm a teapot}.
*@seeHTCPCP/1.0*/I_AM_A_TEAPOT(418, "I'm a teapot"),/***@deprecatedSee WebDAV Draft Changes*/@Deprecated
INSUFFICIENT_SPACE_ON_RESOURCE(419, "Insufficient Space On Resource"),/***@deprecatedSee WebDAV Draft Changes*/@Deprecated
METHOD_FAILURE(420, "Method Failure"),/***@deprecatedSee WebDAV Draft Changes*/@Deprecated
DESTINATION_LOCKED(421, "Destination Locked"),/*** {@code422 Unprocessable Entity}.
*@seeWebDAV*/UNPROCESSABLE_ENTITY(422, "Unprocessable Entity"),/*** {@code423 Locked}.
*@seeWebDAV*/LOCKED(423, "Locked"),/*** {@code424 Failed Dependency}.
*@seeWebDAV*/FAILED_DEPENDENCY(424, "Failed Dependency"),/*** {@code426 Upgrade Required}.
*@seeUpgrading to TLS Within HTTP/1.1*/UPGRADE_REQUIRED(426, "Upgrade Required"),/*** {@code428 Precondition Required}.
*@seeAdditional HTTP Status Codes*/PRECONDITION_REQUIRED(428, "Precondition Required"),/*** {@code429 Too Many Requests}.
*@seeAdditional HTTP Status Codes*/TOO_MANY_REQUESTS(429, "Too Many Requests"),/*** {@code431 Request Header Fields Too Large}.
*@seeAdditional HTTP Status Codes*/REQUEST_HEADER_FIELDS_TOO_LARGE(431, "Request Header Fields Too Large"),/*** {@code451 Unavailable For Legal Reasons}.
* An HTTP Status Code to Report Legal Obstacles
*@since4.3*/UNAVAILABLE_FOR_LEGAL_REASONS(451, "Unavailable For Legal Reasons"),//--- 5xx Server Error ---
/*** {@code500 Internal Server Error}.
*@seeHTTP/1.1: Semantics and Content, section 6.6.1*/INTERNAL_SERVER_ERROR(500, "Internal Server Error"),/*** {@code501 Not Implemented}.
*@seeHTTP/1.1: Semantics and Content, section 6.6.2*/NOT_IMPLEMENTED(501, "Not Implemented"),/*** {@code502 Bad Gateway}.
*@seeHTTP/1.1: Semantics and Content, section 6.6.3*/BAD_GATEWAY(502, "Bad Gateway"),/*** {@code503 Service Unavailable}.
*@seeHTTP/1.1: Semantics and Content, section 6.6.4*/SERVICE_UNAVAILABLE(503, "Service Unavailable"),/*** {@code504 Gateway Timeout}.
*@seeHTTP/1.1: Semantics and Content, section 6.6.5*/GATEWAY_TIMEOUT(504, "Gateway Timeout"),/*** {@code505 HTTP Version Not Supported}.
*@seeHTTP/1.1: Semantics and Content, section 6.6.6*/HTTP_VERSION_NOT_SUPPORTED(505, "HTTP Version not supported"),/*** {@code506 Variant Also Negotiates}
*@seeTransparent Content Negotiation*/VARIANT_ALSO_NEGOTIATES(506, "Variant Also Negotiates"),/*** {@code507 Insufficient Storage}
*@seeWebDAV*/INSUFFICIENT_STORAGE(507, "Insufficient Storage"),/*** {@code508 Loop Detected}
*@seeWebDAV Binding Extensions*/LOOP_DETECTED(508, "Loop Detected"),/*** {@code509 Bandwidth Limit Exceeded}*/BANDWIDTH_LIMIT_EXCEEDED(509, "Bandwidth Limit Exceeded"),/*** {@code510 Not Extended}
*@seeHTTP Extension Framework*/NOT_EXTENDED(510, "Not Extended"),/*** {@code511 Network Authentication Required}.
*@seeAdditional HTTP Status Codes*/NETWORK_AUTHENTICATION_REQUIRED(511, "Network Authentication Required");private final intvalue;private finalString reasonPhrase;
HttpStatus(intvalue, String reasonPhrase) {this.value =value;this.reasonPhrase =reasonPhrase;
}/*** Return the integer value of this status code.*/
public intvalue() {return this.value;
}/*** Return the reason phrase of this status code.*/
publicString getReasonPhrase() {return this.reasonPhrase;
}/*** Whether this status code is in the HTTP series
* {@linkorg.springframework.http.HttpStatus.Series#INFORMATIONAL}.
* This is a shortcut for checking the value of {@link#series()}.*/
public booleanis1xxInformational() {returnSeries.INFORMATIONAL.equals(series());
}/*** Whether this status code is in the HTTP series
* {@linkorg.springframework.http.HttpStatus.Series#SUCCESSFUL}.
* This is a shortcut for checking the value of {@link#series()}.*/
public booleanis2xxSuccessful() {returnSeries.SUCCESSFUL.equals(series());
}/*** Whether this status code is in the HTTP series
* {@linkorg.springframework.http.HttpStatus.Series#REDIRECTION}.
* This is a shortcut for checking the value of {@link#series()}.*/
public booleanis3xxRedirection() {returnSeries.REDIRECTION.equals(series());
}/*** Whether this status code is in the HTTP series
* {@linkorg.springframework.http.HttpStatus.Series#CLIENT_ERROR}.
* This is a shortcut for checking the value of {@link#series()}.*/
public booleanis4xxClientError() {returnSeries.CLIENT_ERROR.equals(series());
}/*** Whether this status code is in the HTTP series
* {@linkorg.springframework.http.HttpStatus.Series#SERVER_ERROR}.
* This is a shortcut for checking the value of {@link#series()}.*/
public booleanis5xxServerError() {returnSeries.SERVER_ERROR.equals(series());
}/*** Returns the HTTP status series of this status code.
*@seeHttpStatus.Series*/
publicSeries series() {return Series.valueOf(this);
}/*** Return a string representation of this status code.*/@OverridepublicString toString() {return Integer.toString(this.value);
}/*** Return the enum constant of this type with the specified numeric value.
*@paramstatusCode the numeric value of the enum to be returned
*@returnthe enum constant with the specified numeric value
*@throwsIllegalArgumentException if this enum has no constant for the specified numeric value*/
public static HttpStatus valueOf(intstatusCode) {for(HttpStatus status : values()) {if (status.value ==statusCode) {returnstatus;
}
}throw new IllegalArgumentException("No matching constant for [" + statusCode + "]");
}/*** Enumeration of HTTP status series.
*
Retrievable via {@linkHttpStatus#series()}.*/
public enumSeries {
INFORMATIONAL(1),
SUCCESSFUL(2),
REDIRECTION(3),
CLIENT_ERROR(4),
SERVER_ERROR(5);private final intvalue;
Series(intvalue) {this.value =value;
}/*** Return the integer value of this status series. Ranges from 1 to 5.*/
public intvalue() {return this.value;
}public static Series valueOf(intstatus) {int seriesCode = status / 100;for(Series series : values()) {if (series.value ==seriesCode) {returnseries;
}
}throw new IllegalArgumentException("No matching constant for [" + status + "]");
}public staticSeries valueOf(HttpStatus status) {returnvalueOf(status.value);
}
}
}