2 // ========================================================================
3 // Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
19 package org.eclipse.jetty.http;
23 * HttpStatusCode enum class, for status codes based on various HTTP RFCs. (see
27 * <table border="1" cellpadding="5">
33 * <a href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a></th>
35 * <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a></th>
37 * <a href="http://tools.ietf.org/html/rfc2518">RFC 2518 - WEBDAV</a></th>
41 * <td><strong><code>Informational - 1xx</code></strong></td>
42 * <td colspan="5">{@link #isInformational(int)}</td>
46 * <td>{@link #CONTINUE_100}</td>
51 * <a href="http://tools.ietf.org/html/rfc2616#section-10.1.1">Sec. 10.1.1</a></td>
55 * <td>{@link #SWITCHING_PROTOCOLS_101}</td>
57 * <td>Switching Protocols</td>
60 * <a href="http://tools.ietf.org/html/rfc2616#section-10.1.2">Sec. 10.1.2</a></td>
64 * <td>{@link #PROCESSING_102}</td>
70 * <a href="http://tools.ietf.org/html/rfc2518#section-10.1">Sec. 10.1</a></td>
74 * <td><strong><code>Success - 2xx</code></strong></td>
75 * <td colspan="5">{@link #isSuccess(int)}</td>
79 * <td>{@link #OK_200}</td>
83 * <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td>
85 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.1">Sec. 10.2.1</a></td>
89 * <td>{@link #CREATED_201}</td>
93 * <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td>
95 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.2">Sec. 10.2.2</a></td>
99 * <td>{@link #ACCEPTED_202}</td>
103 * <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td>
105 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.3">Sec. 10.2.3</a></td>
109 * <td>{@link #NON_AUTHORITATIVE_INFORMATION_203}</td>
111 * <td>Non Authoritative Information</td>
114 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.4">Sec. 10.2.4</a></td>
118 * <td>{@link #NO_CONTENT_204}</td>
120 * <td>No Content</td>
122 * <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td>
124 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.5">Sec. 10.2.5</a></td>
128 * <td>{@link #RESET_CONTENT_205}</td>
130 * <td>Reset Content</td>
133 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.6">Sec. 10.2.6</a></td>
137 * <td>{@link #PARTIAL_CONTENT_206}</td>
139 * <td>Partial Content</td>
142 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.7">Sec. 10.2.7</a></td>
146 * <td>{@link #MULTI_STATUS_207}</td>
148 * <td>Multi-Status</td>
152 * <a href="http://tools.ietf.org/html/rfc2518#section-10.2">Sec. 10.2</a></td>
156 * <td><strike>207</strike></td>
157 * <td><strike>Partial Update OK</strike></td>
161 * "http://www.w3.org/Protocols/HTTP/1.1/draft-ietf-http-v11-spec-rev-01.txt"
167 * <td><strong><code>Redirection - 3xx</code></strong></td>
168 * <td colspan="5">{@link #isRedirection(int)}</td>
172 * <td>{@link #MULTIPLE_CHOICES_300}</td>
174 * <td>Multiple Choices</td>
176 * <a href="http://tools.ietf.org/html/rfc1945#section-9.3">Sec. 9.3</a></td>
178 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.1">Sec. 10.3.1</a></td>
182 * <td>{@link #MOVED_PERMANENTLY_301}</td>
184 * <td>Moved Permanently</td>
186 * <a href="http://tools.ietf.org/html/rfc1945#section-9.3">Sec. 9.3</a></td>
188 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.2">Sec. 10.3.2</a></td>
192 * <td>{@link #MOVED_TEMPORARILY_302}</td>
194 * <td>Moved Temporarily</td>
196 * <a href="http://tools.ietf.org/html/rfc1945#section-9.3">Sec. 9.3</a></td>
197 * <td>(now "<code>302 Found</code>")</td>
201 * <td>{@link #FOUND_302}</td>
204 * <td>(was "<code>302 Moved Temporarily</code>")</td>
206 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.3">Sec. 10.3.3</a></td>
210 * <td>{@link #SEE_OTHER_303}</td>
215 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.4">Sec. 10.3.4</a></td>
219 * <td>{@link #NOT_MODIFIED_304}</td>
221 * <td>Not Modified</td>
223 * <a href="http://tools.ietf.org/html/rfc1945#section-9.3">Sec. 9.3</a></td>
225 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.5">Sec. 10.3.5</a></td>
229 * <td>{@link #USE_PROXY_305}</td>
234 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.6">Sec. 10.3.6</a></td>
240 * <td><em>(Unused)</em></td>
243 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.7">Sec. 10.3.7</a></td>
247 * <td>{@link #TEMPORARY_REDIRECT_307}</td>
249 * <td>Temporary Redirect</td>
252 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.8">Sec. 10.3.8</a></td>
257 * <td><strong><code>Client Error - 4xx</code></strong></td>
258 * <td colspan="5">{@link #isClientError(int)}</td>
262 * <td>{@link #BAD_REQUEST_400}</td>
264 * <td>Bad Request</td>
266 * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
268 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.1">Sec. 10.4.1</a></td>
272 * <td>{@link #UNAUTHORIZED_401}</td>
274 * <td>Unauthorized</td>
276 * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
278 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.2">Sec. 10.4.2</a></td>
282 * <td>{@link #PAYMENT_REQUIRED_402}</td>
284 * <td>Payment Required</td>
286 * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
288 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.3">Sec. 10.4.3</a></td>
292 * <td>{@link #FORBIDDEN_403}</td>
296 * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
298 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.4">Sec. 10.4.4</a></td>
302 * <td>{@link #NOT_FOUND_404}</td>
306 * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
308 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.5">Sec. 10.4.5</a></td>
312 * <td>{@link #METHOD_NOT_ALLOWED_405}</td>
314 * <td>Method Not Allowed</td>
317 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.6">Sec. 10.4.6</a></td>
321 * <td>{@link #NOT_ACCEPTABLE_406}</td>
323 * <td>Not Acceptable</td>
326 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.7">Sec. 10.4.7</a></td>
330 * <td>{@link #PROXY_AUTHENTICATION_REQUIRED_407}</td>
332 * <td>Proxy Authentication Required</td>
335 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.8">Sec. 10.4.8</a></td>
339 * <td>{@link #REQUEST_TIMEOUT_408}</td>
341 * <td>Request Timeout</td>
344 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.9">Sec. 10.4.9</a></td>
348 * <td>{@link #CONFLICT_409}</td>
353 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.10">Sec. 10.4.10</a>
358 * <td>{@link #GONE_410}</td>
363 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.11">Sec. 10.4.11</a>
368 * <td>{@link #LENGTH_REQUIRED_411}</td>
370 * <td>Length Required</td>
373 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.12">Sec. 10.4.12</a>
378 * <td>{@link #PRECONDITION_FAILED_412}</td>
380 * <td>Precondition Failed</td>
383 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.13">Sec. 10.4.13</a>
388 * <td>{@link #REQUEST_ENTITY_TOO_LARGE_413}</td>
390 * <td>Request Entity Too Large</td>
393 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.14">Sec. 10.4.14</a>
398 * <td>{@link #REQUEST_URI_TOO_LONG_414}</td>
400 * <td>Request-URI Too Long</td>
403 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.15">Sec. 10.4.15</a>
408 * <td>{@link #UNSUPPORTED_MEDIA_TYPE_415}</td>
410 * <td>Unsupported Media Type</td>
413 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.16">Sec. 10.4.16</a>
418 * <td>{@link #REQUESTED_RANGE_NOT_SATISFIABLE_416}</td>
420 * <td>Requested Range Not Satisfiable</td>
423 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.17">Sec. 10.4.17</a>
428 * <td>{@link #EXPECTATION_FAILED_417}</td>
430 * <td>Expectation Failed</td>
433 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.18">Sec. 10.4.18</a>
439 * <td><strike>418</strike></td>
440 * <td><strike>Reauthentication Required</strike></td>
444 * "http://tools.ietf.org/html/draft-ietf-http-v11-spec-rev-01#section-10.4.19"
450 * <td><strike>418</strike></td>
451 * <td><strike>Unprocessable Entity</strike></td>
456 * "http://tools.ietf.org/html/draft-ietf-webdav-protocol-05#section-10.3"
461 * <td><strike>419</strike></td>
462 * <td><strike>Proxy Reauthentication Required</stike></td>
466 * "http://tools.ietf.org/html/draft-ietf-http-v11-spec-rev-01#section-10.4.20"
472 * <td><strike>419</strike></td>
473 * <td><strike>Insufficient Space on Resource</stike></td>
478 * "http://tools.ietf.org/html/draft-ietf-webdav-protocol-05#section-10.4"
483 * <td><strike>420</strike></td>
484 * <td><strike>Method Failure</strike></td>
489 * "http://tools.ietf.org/html/draft-ietf-webdav-protocol-05#section-10.5"
495 * <td><em>(Unused)</em></td>
501 * <td>{@link #UNPROCESSABLE_ENTITY_422}</td>
503 * <td>Unprocessable Entity</td>
507 * <a href="http://tools.ietf.org/html/rfc2518#section-10.3">Sec. 10.3</a></td>
510 * <td>{@link #LOCKED_423}</td>
516 * <a href="http://tools.ietf.org/html/rfc2518#section-10.4">Sec. 10.4</a></td>
519 * <td>{@link #FAILED_DEPENDENCY_424}</td>
521 * <td>Failed Dependency</td>
525 * <a href="http://tools.ietf.org/html/rfc2518#section-10.5">Sec. 10.5</a></td>
529 * <td><strong><code>Server Error - 5xx</code></strong></td>
530 * <td colspan="5">{@link #isServerError(int)}</td>
534 * <td>{@link #INTERNAL_SERVER_ERROR_500}</td>
536 * <td>Internal Server Error</td>
538 * <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td>
540 * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.1">Sec. 10.5.1</a></td>
544 * <td>{@link #NOT_IMPLEMENTED_501}</td>
546 * <td>Not Implemented</td>
548 * <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td>
550 * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.2">Sec. 10.5.2</a></td>
554 * <td>{@link #BAD_GATEWAY_502}</td>
556 * <td>Bad Gateway</td>
558 * <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td>
560 * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.3">Sec. 10.5.3</a></td>
564 * <td>{@link #SERVICE_UNAVAILABLE_503}</td>
566 * <td>Service Unavailable</td>
568 * <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td>
570 * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.4">Sec. 10.5.4</a></td>
574 * <td>{@link #GATEWAY_TIMEOUT_504}</td>
576 * <td>Gateway Timeout</td>
579 * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.5">Sec. 10.5.5</a></td>
583 * <td>{@link #HTTP_VERSION_NOT_SUPPORTED_505}</td>
585 * <td>HTTP Version Not Supported</td>
588 * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.6">Sec. 10.5.6</a></td>
594 * <td><em>(Unused)</em></td>
600 * <td>{@link #INSUFFICIENT_STORAGE_507}</td>
602 * <td>Insufficient Storage</td>
606 * <a href="http://tools.ietf.org/html/rfc2518#section-10.6">Sec. 10.6</a></td>
613 public class HttpStatus
615 public final static int CONTINUE_100 = 100;
616 public final static int SWITCHING_PROTOCOLS_101 = 101;
617 public final static int PROCESSING_102 = 102;
619 public final static int OK_200 = 200;
620 public final static int CREATED_201 = 201;
621 public final static int ACCEPTED_202 = 202;
622 public final static int NON_AUTHORITATIVE_INFORMATION_203 = 203;
623 public final static int NO_CONTENT_204 = 204;
624 public final static int RESET_CONTENT_205 = 205;
625 public final static int PARTIAL_CONTENT_206 = 206;
626 public final static int MULTI_STATUS_207 = 207;
628 public final static int MULTIPLE_CHOICES_300 = 300;
629 public final static int MOVED_PERMANENTLY_301 = 301;
630 public final static int MOVED_TEMPORARILY_302 = 302;
631 public final static int FOUND_302 = 302;
632 public final static int SEE_OTHER_303 = 303;
633 public final static int NOT_MODIFIED_304 = 304;
634 public final static int USE_PROXY_305 = 305;
635 public final static int TEMPORARY_REDIRECT_307 = 307;
637 public final static int BAD_REQUEST_400 = 400;
638 public final static int UNAUTHORIZED_401 = 401;
639 public final static int PAYMENT_REQUIRED_402 = 402;
640 public final static int FORBIDDEN_403 = 403;
641 public final static int NOT_FOUND_404 = 404;
642 public final static int METHOD_NOT_ALLOWED_405 = 405;
643 public final static int NOT_ACCEPTABLE_406 = 406;
644 public final static int PROXY_AUTHENTICATION_REQUIRED_407 = 407;
645 public final static int REQUEST_TIMEOUT_408 = 408;
646 public final static int CONFLICT_409 = 409;
647 public final static int GONE_410 = 410;
648 public final static int LENGTH_REQUIRED_411 = 411;
649 public final static int PRECONDITION_FAILED_412 = 412;
650 public final static int REQUEST_ENTITY_TOO_LARGE_413 = 413;
651 public final static int REQUEST_URI_TOO_LONG_414 = 414;
652 public final static int UNSUPPORTED_MEDIA_TYPE_415 = 415;
653 public final static int REQUESTED_RANGE_NOT_SATISFIABLE_416 = 416;
654 public final static int EXPECTATION_FAILED_417 = 417;
655 public final static int UNPROCESSABLE_ENTITY_422 = 422;
656 public final static int LOCKED_423 = 423;
657 public final static int FAILED_DEPENDENCY_424 = 424;
659 public final static int INTERNAL_SERVER_ERROR_500 = 500;
660 public final static int NOT_IMPLEMENTED_501 = 501;
661 public final static int BAD_GATEWAY_502 = 502;
662 public final static int SERVICE_UNAVAILABLE_503 = 503;
663 public final static int GATEWAY_TIMEOUT_504 = 504;
664 public final static int HTTP_VERSION_NOT_SUPPORTED_505 = 505;
665 public final static int INSUFFICIENT_STORAGE_507 = 507;
667 public static final int MAX_CODE = 507;
670 private static final Code[] codeMap = new Code[MAX_CODE+1];
674 for (Code code : Code.values())
676 codeMap[code._code] = code;
684 * --------------------------------------------------------------------
685 * Informational messages in 1xx series. As defined by ... RFC 1945 -
686 * HTTP/1.0 RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
689 /** <code>100 Continue</code> */
690 CONTINUE(CONTINUE_100, "Continue"),
691 /** <code>101 Switching Protocols</code> */
692 SWITCHING_PROTOCOLS(SWITCHING_PROTOCOLS_101, "Switching Protocols"),
693 /** <code>102 Processing</code> */
694 PROCESSING(PROCESSING_102, "Processing"),
697 * --------------------------------------------------------------------
698 * Success messages in 2xx series. As defined by ... RFC 1945 - HTTP/1.0
699 * RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
702 /** <code>200 OK</code> */
704 /** <code>201 Created</code> */
705 CREATED(CREATED_201, "Created"),
706 /** <code>202 Accepted</code> */
707 ACCEPTED(ACCEPTED_202, "Accepted"),
708 /** <code>203 Non Authoritative Information</code> */
709 NON_AUTHORITATIVE_INFORMATION(NON_AUTHORITATIVE_INFORMATION_203, "Non Authoritative Information"),
710 /** <code>204 No Content</code> */
711 NO_CONTENT(NO_CONTENT_204, "No Content"),
712 /** <code>205 Reset Content</code> */
713 RESET_CONTENT(RESET_CONTENT_205, "Reset Content"),
714 /** <code>206 Partial Content</code> */
715 PARTIAL_CONTENT(PARTIAL_CONTENT_206, "Partial Content"),
716 /** <code>207 Multi-Status</code> */
717 MULTI_STATUS(MULTI_STATUS_207, "Multi-Status"),
720 * --------------------------------------------------------------------
721 * Redirection messages in 3xx series. As defined by ... RFC 1945 -
722 * HTTP/1.0 RFC 2616 - HTTP/1.1
725 /** <code>300 Mutliple Choices</code> */
726 MULTIPLE_CHOICES(MULTIPLE_CHOICES_300, "Multiple Choices"),
727 /** <code>301 Moved Permanently</code> */
728 MOVED_PERMANENTLY(MOVED_PERMANENTLY_301, "Moved Permanently"),
729 /** <code>302 Moved Temporarily</code> */
730 MOVED_TEMPORARILY(MOVED_TEMPORARILY_302, "Moved Temporarily"),
731 /** <code>302 Found</code> */
732 FOUND(FOUND_302, "Found"),
733 /** <code>303 See Other</code> */
734 SEE_OTHER(SEE_OTHER_303, "See Other"),
735 /** <code>304 Not Modified</code> */
736 NOT_MODIFIED(NOT_MODIFIED_304, "Not Modified"),
737 /** <code>305 Use Proxy</code> */
738 USE_PROXY(USE_PROXY_305, "Use Proxy"),
739 /** <code>307 Temporary Redirect</code> */
740 TEMPORARY_REDIRECT(TEMPORARY_REDIRECT_307, "Temporary Redirect"),
743 * --------------------------------------------------------------------
744 * Client Error messages in 4xx series. As defined by ... RFC 1945 -
745 * HTTP/1.0 RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
748 /** <code>400 Bad Request</code> */
749 BAD_REQUEST(BAD_REQUEST_400, "Bad Request"),
750 /** <code>401 Unauthorized</code> */
751 UNAUTHORIZED(UNAUTHORIZED_401, "Unauthorized"),
752 /** <code>402 Payment Required</code> */
753 PAYMENT_REQUIRED(PAYMENT_REQUIRED_402, "Payment Required"),
754 /** <code>403 Forbidden</code> */
755 FORBIDDEN(FORBIDDEN_403, "Forbidden"),
756 /** <code>404 Not Found</code> */
757 NOT_FOUND(NOT_FOUND_404, "Not Found"),
758 /** <code>405 Method Not Allowed</code> */
759 METHOD_NOT_ALLOWED(METHOD_NOT_ALLOWED_405, "Method Not Allowed"),
760 /** <code>406 Not Acceptable</code> */
761 NOT_ACCEPTABLE(NOT_ACCEPTABLE_406, "Not Acceptable"),
762 /** <code>407 Proxy Authentication Required</code> */
763 PROXY_AUTHENTICATION_REQUIRED(PROXY_AUTHENTICATION_REQUIRED_407, "Proxy Authentication Required"),
764 /** <code>408 Request Timeout</code> */
765 REQUEST_TIMEOUT(REQUEST_TIMEOUT_408, "Request Timeout"),
766 /** <code>409 Conflict</code> */
767 CONFLICT(CONFLICT_409, "Conflict"),
768 /** <code>410 Gone</code> */
769 GONE(GONE_410, "Gone"),
770 /** <code>411 Length Required</code> */
771 LENGTH_REQUIRED(LENGTH_REQUIRED_411, "Length Required"),
772 /** <code>412 Precondition Failed</code> */
773 PRECONDITION_FAILED(PRECONDITION_FAILED_412, "Precondition Failed"),
774 /** <code>413 Request Entity Too Large</code> */
775 REQUEST_ENTITY_TOO_LARGE(REQUEST_ENTITY_TOO_LARGE_413, "Request Entity Too Large"),
776 /** <code>414 Request-URI Too Long</code> */
777 REQUEST_URI_TOO_LONG(REQUEST_URI_TOO_LONG_414, "Request-URI Too Long"),
778 /** <code>415 Unsupported Media Type</code> */
779 UNSUPPORTED_MEDIA_TYPE(UNSUPPORTED_MEDIA_TYPE_415, "Unsupported Media Type"),
780 /** <code>416 Requested Range Not Satisfiable</code> */
781 REQUESTED_RANGE_NOT_SATISFIABLE(REQUESTED_RANGE_NOT_SATISFIABLE_416, "Requested Range Not Satisfiable"),
782 /** <code>417 Expectation Failed</code> */
783 EXPECTATION_FAILED(EXPECTATION_FAILED_417, "Expectation Failed"),
784 /** <code>422 Unprocessable Entity</code> */
785 UNPROCESSABLE_ENTITY(UNPROCESSABLE_ENTITY_422, "Unprocessable Entity"),
786 /** <code>423 Locked</code> */
787 LOCKED(LOCKED_423, "Locked"),
788 /** <code>424 Failed Dependency</code> */
789 FAILED_DEPENDENCY(FAILED_DEPENDENCY_424, "Failed Dependency"),
792 * --------------------------------------------------------------------
793 * Server Error messages in 5xx series. As defined by ... RFC 1945 -
794 * HTTP/1.0 RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
797 /** <code>500 Server Error</code> */
798 INTERNAL_SERVER_ERROR(INTERNAL_SERVER_ERROR_500, "Server Error"),
799 /** <code>501 Not Implemented</code> */
800 NOT_IMPLEMENTED(NOT_IMPLEMENTED_501, "Not Implemented"),
801 /** <code>502 Bad Gateway</code> */
802 BAD_GATEWAY(BAD_GATEWAY_502, "Bad Gateway"),
803 /** <code>503 Service Unavailable</code> */
804 SERVICE_UNAVAILABLE(SERVICE_UNAVAILABLE_503, "Service Unavailable"),
805 /** <code>504 Gateway Timeout</code> */
806 GATEWAY_TIMEOUT(GATEWAY_TIMEOUT_504, "Gateway Timeout"),
807 /** <code>505 HTTP Version Not Supported</code> */
808 HTTP_VERSION_NOT_SUPPORTED(HTTP_VERSION_NOT_SUPPORTED_505, "HTTP Version Not Supported"),
809 /** <code>507 Insufficient Storage</code> */
810 INSUFFICIENT_STORAGE(INSUFFICIENT_STORAGE_507, "Insufficient Storage");
812 private final int _code;
813 private final String _message;
815 private Code(int code, String message)
826 public String getMessage()
832 public boolean equals(int code)
834 return (this._code == code);
838 public String toString()
840 return String.format("[%03d %s]",this._code,this.getMessage());
844 * Simple test against an code to determine if it falls into the
845 * <code>Informational</code> message category as defined in the <a
846 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
847 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
850 * @return true if within range of codes that belongs to
851 * <code>Informational</code> messages.
853 public boolean isInformational()
855 return HttpStatus.isInformational(this._code);
859 * Simple test against an code to determine if it falls into the
860 * <code>Success</code> message category as defined in the <a
861 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
862 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
865 * @return true if within range of codes that belongs to
866 * <code>Success</code> messages.
868 public boolean isSuccess()
870 return HttpStatus.isSuccess(this._code);
874 * Simple test against an code to determine if it falls into the
875 * <code>Redirection</code> message category as defined in the <a
876 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
877 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
880 * @return true if within range of codes that belongs to
881 * <code>Redirection</code> messages.
883 public boolean isRedirection()
885 return HttpStatus.isRedirection(this._code);
889 * Simple test against an code to determine if it falls into the
890 * <code>Client Error</code> message category as defined in the <a
891 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
892 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
895 * @return true if within range of codes that belongs to
896 * <code>Client Error</code> messages.
898 public boolean isClientError()
900 return HttpStatus.isClientError(this._code);
904 * Simple test against an code to determine if it falls into the
905 * <code>Server Error</code> message category as defined in the <a
906 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
907 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
910 * @return true if within range of codes that belongs to
911 * <code>Server Error</code> messages.
913 public boolean isServerError()
915 return HttpStatus.isServerError(this._code);
921 * Get the HttpStatusCode for a specific code
924 * the code to lookup.
925 * @return the {@link HttpStatus} if found, or null if not found.
927 public static Code getCode(int code)
929 if (code <= MAX_CODE)
931 return codeMap[code];
937 * Get the status message for a specific code.
940 * the code to look up
941 * @return the specific message, or the code number itself if code
942 * does not match known list.
944 public static String getMessage(int code)
946 Code codeEnum = getCode(code);
947 if (codeEnum != null)
949 return codeEnum.getMessage();
953 return Integer.toString(code);
958 * Simple test against an code to determine if it falls into the
959 * <code>Informational</code> message category as defined in the <a
960 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
961 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
965 * @return true if within range of codes that belongs to
966 * <code>Informational</code> messages.
968 public static boolean isInformational(int code)
970 return ((100 <= code) && (code <= 199));
974 * Simple test against an code to determine if it falls into the
975 * <code>Success</code> message category as defined in the <a
976 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
977 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
981 * @return true if within range of codes that belongs to
982 * <code>Success</code> messages.
984 public static boolean isSuccess(int code)
986 return ((200 <= code) && (code <= 299));
990 * Simple test against an code to determine if it falls into the
991 * <code>Redirection</code> message category as defined in the <a
992 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
993 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
997 * @return true if within range of codes that belongs to
998 * <code>Redirection</code> messages.
1000 public static boolean isRedirection(int code)
1002 return ((300 <= code) && (code <= 399));
1006 * Simple test against an code to determine if it falls into the
1007 * <code>Client Error</code> message category as defined in the <a
1008 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
1009 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
1013 * @return true if within range of codes that belongs to
1014 * <code>Client Error</code> messages.
1016 public static boolean isClientError(int code)
1018 return ((400 <= code) && (code <= 499));
1022 * Simple test against an code to determine if it falls into the
1023 * <code>Server Error</code> message category as defined in the <a
1024 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
1025 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
1029 * @return true if within range of codes that belongs to
1030 * <code>Server Error</code> messages.
1032 public static boolean isServerError(int code)
1034 return ((500 <= code) && (code <= 599));