2 // ========================================================================
3 // Copyright (c) 1995-2014 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 NOT_SET_000 = 0;
616 public final static int CONTINUE_100 = 100;
617 public final static int SWITCHING_PROTOCOLS_101 = 101;
618 public final static int PROCESSING_102 = 102;
620 public final static int OK_200 = 200;
621 public final static int CREATED_201 = 201;
622 public final static int ACCEPTED_202 = 202;
623 public final static int NON_AUTHORITATIVE_INFORMATION_203 = 203;
624 public final static int NO_CONTENT_204 = 204;
625 public final static int RESET_CONTENT_205 = 205;
626 public final static int PARTIAL_CONTENT_206 = 206;
627 public final static int MULTI_STATUS_207 = 207;
629 public final static int MULTIPLE_CHOICES_300 = 300;
630 public final static int MOVED_PERMANENTLY_301 = 301;
631 public final static int MOVED_TEMPORARILY_302 = 302;
632 public final static int FOUND_302 = 302;
633 public final static int SEE_OTHER_303 = 303;
634 public final static int NOT_MODIFIED_304 = 304;
635 public final static int USE_PROXY_305 = 305;
636 public final static int TEMPORARY_REDIRECT_307 = 307;
638 public final static int BAD_REQUEST_400 = 400;
639 public final static int UNAUTHORIZED_401 = 401;
640 public final static int PAYMENT_REQUIRED_402 = 402;
641 public final static int FORBIDDEN_403 = 403;
642 public final static int NOT_FOUND_404 = 404;
643 public final static int METHOD_NOT_ALLOWED_405 = 405;
644 public final static int NOT_ACCEPTABLE_406 = 406;
645 public final static int PROXY_AUTHENTICATION_REQUIRED_407 = 407;
646 public final static int REQUEST_TIMEOUT_408 = 408;
647 public final static int CONFLICT_409 = 409;
648 public final static int GONE_410 = 410;
649 public final static int LENGTH_REQUIRED_411 = 411;
650 public final static int PRECONDITION_FAILED_412 = 412;
651 public final static int REQUEST_ENTITY_TOO_LARGE_413 = 413;
652 public final static int REQUEST_URI_TOO_LONG_414 = 414;
653 public final static int UNSUPPORTED_MEDIA_TYPE_415 = 415;
654 public final static int REQUESTED_RANGE_NOT_SATISFIABLE_416 = 416;
655 public final static int EXPECTATION_FAILED_417 = 417;
656 public final static int UNPROCESSABLE_ENTITY_422 = 422;
657 public final static int LOCKED_423 = 423;
658 public final static int FAILED_DEPENDENCY_424 = 424;
660 public final static int INTERNAL_SERVER_ERROR_500 = 500;
661 public final static int NOT_IMPLEMENTED_501 = 501;
662 public final static int BAD_GATEWAY_502 = 502;
663 public final static int SERVICE_UNAVAILABLE_503 = 503;
664 public final static int GATEWAY_TIMEOUT_504 = 504;
665 public final static int HTTP_VERSION_NOT_SUPPORTED_505 = 505;
666 public final static int INSUFFICIENT_STORAGE_507 = 507;
668 public static final int MAX_CODE = 507;
671 private static final Code[] codeMap = new Code[MAX_CODE+1];
675 for (Code code : Code.values())
677 codeMap[code._code] = code;
685 * --------------------------------------------------------------------
686 * Informational messages in 1xx series. As defined by ... RFC 1945 -
687 * HTTP/1.0 RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
690 /** <code>100 Continue</code> */
691 CONTINUE(CONTINUE_100, "Continue"),
692 /** <code>101 Switching Protocols</code> */
693 SWITCHING_PROTOCOLS(SWITCHING_PROTOCOLS_101, "Switching Protocols"),
694 /** <code>102 Processing</code> */
695 PROCESSING(PROCESSING_102, "Processing"),
698 * --------------------------------------------------------------------
699 * Success messages in 2xx series. As defined by ... RFC 1945 - HTTP/1.0
700 * RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
703 /** <code>200 OK</code> */
705 /** <code>201 Created</code> */
706 CREATED(CREATED_201, "Created"),
707 /** <code>202 Accepted</code> */
708 ACCEPTED(ACCEPTED_202, "Accepted"),
709 /** <code>203 Non Authoritative Information</code> */
710 NON_AUTHORITATIVE_INFORMATION(NON_AUTHORITATIVE_INFORMATION_203, "Non Authoritative Information"),
711 /** <code>204 No Content</code> */
712 NO_CONTENT(NO_CONTENT_204, "No Content"),
713 /** <code>205 Reset Content</code> */
714 RESET_CONTENT(RESET_CONTENT_205, "Reset Content"),
715 /** <code>206 Partial Content</code> */
716 PARTIAL_CONTENT(PARTIAL_CONTENT_206, "Partial Content"),
717 /** <code>207 Multi-Status</code> */
718 MULTI_STATUS(MULTI_STATUS_207, "Multi-Status"),
721 * --------------------------------------------------------------------
722 * Redirection messages in 3xx series. As defined by ... RFC 1945 -
723 * HTTP/1.0 RFC 2616 - HTTP/1.1
726 /** <code>300 Mutliple Choices</code> */
727 MULTIPLE_CHOICES(MULTIPLE_CHOICES_300, "Multiple Choices"),
728 /** <code>301 Moved Permanently</code> */
729 MOVED_PERMANENTLY(MOVED_PERMANENTLY_301, "Moved Permanently"),
730 /** <code>302 Moved Temporarily</code> */
731 MOVED_TEMPORARILY(MOVED_TEMPORARILY_302, "Moved Temporarily"),
732 /** <code>302 Found</code> */
733 FOUND(FOUND_302, "Found"),
734 /** <code>303 See Other</code> */
735 SEE_OTHER(SEE_OTHER_303, "See Other"),
736 /** <code>304 Not Modified</code> */
737 NOT_MODIFIED(NOT_MODIFIED_304, "Not Modified"),
738 /** <code>305 Use Proxy</code> */
739 USE_PROXY(USE_PROXY_305, "Use Proxy"),
740 /** <code>307 Temporary Redirect</code> */
741 TEMPORARY_REDIRECT(TEMPORARY_REDIRECT_307, "Temporary Redirect"),
744 * --------------------------------------------------------------------
745 * Client Error messages in 4xx series. As defined by ... RFC 1945 -
746 * HTTP/1.0 RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
749 /** <code>400 Bad Request</code> */
750 BAD_REQUEST(BAD_REQUEST_400, "Bad Request"),
751 /** <code>401 Unauthorized</code> */
752 UNAUTHORIZED(UNAUTHORIZED_401, "Unauthorized"),
753 /** <code>402 Payment Required</code> */
754 PAYMENT_REQUIRED(PAYMENT_REQUIRED_402, "Payment Required"),
755 /** <code>403 Forbidden</code> */
756 FORBIDDEN(FORBIDDEN_403, "Forbidden"),
757 /** <code>404 Not Found</code> */
758 NOT_FOUND(NOT_FOUND_404, "Not Found"),
759 /** <code>405 Method Not Allowed</code> */
760 METHOD_NOT_ALLOWED(METHOD_NOT_ALLOWED_405, "Method Not Allowed"),
761 /** <code>406 Not Acceptable</code> */
762 NOT_ACCEPTABLE(NOT_ACCEPTABLE_406, "Not Acceptable"),
763 /** <code>407 Proxy Authentication Required</code> */
764 PROXY_AUTHENTICATION_REQUIRED(PROXY_AUTHENTICATION_REQUIRED_407, "Proxy Authentication Required"),
765 /** <code>408 Request Timeout</code> */
766 REQUEST_TIMEOUT(REQUEST_TIMEOUT_408, "Request Timeout"),
767 /** <code>409 Conflict</code> */
768 CONFLICT(CONFLICT_409, "Conflict"),
769 /** <code>410 Gone</code> */
770 GONE(GONE_410, "Gone"),
771 /** <code>411 Length Required</code> */
772 LENGTH_REQUIRED(LENGTH_REQUIRED_411, "Length Required"),
773 /** <code>412 Precondition Failed</code> */
774 PRECONDITION_FAILED(PRECONDITION_FAILED_412, "Precondition Failed"),
775 /** <code>413 Request Entity Too Large</code> */
776 REQUEST_ENTITY_TOO_LARGE(REQUEST_ENTITY_TOO_LARGE_413, "Request Entity Too Large"),
777 /** <code>414 Request-URI Too Long</code> */
778 REQUEST_URI_TOO_LONG(REQUEST_URI_TOO_LONG_414, "Request-URI Too Long"),
779 /** <code>415 Unsupported Media Type</code> */
780 UNSUPPORTED_MEDIA_TYPE(UNSUPPORTED_MEDIA_TYPE_415, "Unsupported Media Type"),
781 /** <code>416 Requested Range Not Satisfiable</code> */
782 REQUESTED_RANGE_NOT_SATISFIABLE(REQUESTED_RANGE_NOT_SATISFIABLE_416, "Requested Range Not Satisfiable"),
783 /** <code>417 Expectation Failed</code> */
784 EXPECTATION_FAILED(EXPECTATION_FAILED_417, "Expectation Failed"),
785 /** <code>422 Unprocessable Entity</code> */
786 UNPROCESSABLE_ENTITY(UNPROCESSABLE_ENTITY_422, "Unprocessable Entity"),
787 /** <code>423 Locked</code> */
788 LOCKED(LOCKED_423, "Locked"),
789 /** <code>424 Failed Dependency</code> */
790 FAILED_DEPENDENCY(FAILED_DEPENDENCY_424, "Failed Dependency"),
793 * --------------------------------------------------------------------
794 * Server Error messages in 5xx series. As defined by ... RFC 1945 -
795 * HTTP/1.0 RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
798 /** <code>500 Server Error</code> */
799 INTERNAL_SERVER_ERROR(INTERNAL_SERVER_ERROR_500, "Server Error"),
800 /** <code>501 Not Implemented</code> */
801 NOT_IMPLEMENTED(NOT_IMPLEMENTED_501, "Not Implemented"),
802 /** <code>502 Bad Gateway</code> */
803 BAD_GATEWAY(BAD_GATEWAY_502, "Bad Gateway"),
804 /** <code>503 Service Unavailable</code> */
805 SERVICE_UNAVAILABLE(SERVICE_UNAVAILABLE_503, "Service Unavailable"),
806 /** <code>504 Gateway Timeout</code> */
807 GATEWAY_TIMEOUT(GATEWAY_TIMEOUT_504, "Gateway Timeout"),
808 /** <code>505 HTTP Version Not Supported</code> */
809 HTTP_VERSION_NOT_SUPPORTED(HTTP_VERSION_NOT_SUPPORTED_505, "HTTP Version Not Supported"),
810 /** <code>507 Insufficient Storage</code> */
811 INSUFFICIENT_STORAGE(INSUFFICIENT_STORAGE_507, "Insufficient Storage");
813 private final int _code;
814 private final String _message;
816 private Code(int code, String message)
827 public String getMessage()
833 public boolean equals(int code)
835 return (this._code == code);
839 public String toString()
841 return String.format("[%03d %s]",this._code,this.getMessage());
845 * Simple test against an code to determine if it falls into the
846 * <code>Informational</code> message category as defined in the <a
847 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
848 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
851 * @return true if within range of codes that belongs to
852 * <code>Informational</code> messages.
854 public boolean isInformational()
856 return HttpStatus.isInformational(this._code);
860 * Simple test against an code to determine if it falls into the
861 * <code>Success</code> message category as defined in the <a
862 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
863 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
866 * @return true if within range of codes that belongs to
867 * <code>Success</code> messages.
869 public boolean isSuccess()
871 return HttpStatus.isSuccess(this._code);
875 * Simple test against an code to determine if it falls into the
876 * <code>Redirection</code> message category as defined in the <a
877 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
878 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
881 * @return true if within range of codes that belongs to
882 * <code>Redirection</code> messages.
884 public boolean isRedirection()
886 return HttpStatus.isRedirection(this._code);
890 * Simple test against an code to determine if it falls into the
891 * <code>Client Error</code> message category as defined in the <a
892 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
893 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
896 * @return true if within range of codes that belongs to
897 * <code>Client Error</code> messages.
899 public boolean isClientError()
901 return HttpStatus.isClientError(this._code);
905 * Simple test against an code to determine if it falls into the
906 * <code>Server Error</code> message category as defined in the <a
907 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
908 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
911 * @return true if within range of codes that belongs to
912 * <code>Server Error</code> messages.
914 public boolean isServerError()
916 return HttpStatus.isServerError(this._code);
922 * Get the HttpStatusCode for a specific code
925 * the code to lookup.
926 * @return the {@link HttpStatus} if found, or null if not found.
928 public static Code getCode(int code)
930 if (code <= MAX_CODE)
932 return codeMap[code];
938 * Get the status message for a specific code.
941 * the code to look up
942 * @return the specific message, or the code number itself if code
943 * does not match known list.
945 public static String getMessage(int code)
947 Code codeEnum = getCode(code);
948 if (codeEnum != null)
950 return codeEnum.getMessage();
954 return Integer.toString(code);
959 * Simple test against an code to determine if it falls into the
960 * <code>Informational</code> message category as defined in the <a
961 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
962 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
966 * @return true if within range of codes that belongs to
967 * <code>Informational</code> messages.
969 public static boolean isInformational(int code)
971 return ((100 <= code) && (code <= 199));
975 * Simple test against an code to determine if it falls into the
976 * <code>Success</code> message category as defined in the <a
977 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
978 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
982 * @return true if within range of codes that belongs to
983 * <code>Success</code> messages.
985 public static boolean isSuccess(int code)
987 return ((200 <= code) && (code <= 299));
991 * Simple test against an code to determine if it falls into the
992 * <code>Redirection</code> message category as defined in the <a
993 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
994 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
998 * @return true if within range of codes that belongs to
999 * <code>Redirection</code> messages.
1001 public static boolean isRedirection(int code)
1003 return ((300 <= code) && (code <= 399));
1007 * Simple test against an code to determine if it falls into the
1008 * <code>Client Error</code> message category as defined in the <a
1009 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
1010 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
1014 * @return true if within range of codes that belongs to
1015 * <code>Client Error</code> messages.
1017 public static boolean isClientError(int code)
1019 return ((400 <= code) && (code <= 499));
1023 * Simple test against an code to determine if it falls into the
1024 * <code>Server Error</code> message category as defined in the <a
1025 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
1026 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
1030 * @return true if within range of codes that belongs to
1031 * <code>Server Error</code> messages.
1033 public static boolean isServerError(int code)
1035 return ((500 <= code) && (code <= 599));