]> WPIA git - gigi.git/blob - lib/jetty/org/eclipse/jetty/http/HttpStatus.java
Merge "Update notes about password security"
[gigi.git] / lib / jetty / org / eclipse / jetty / http / HttpStatus.java
1 //
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.
8 //
9 //      The Eclipse Public License is available at
10 //      http://www.eclipse.org/legal/epl-v10.html
11 //
12 //      The Apache License v2.0 is available at
13 //      http://www.opensource.org/licenses/apache2.0.php
14 //
15 //  You may elect to redistribute this code under either of these licenses.
16 //  ========================================================================
17 //
18
19 package org.eclipse.jetty.http;
20
21 /**
22  * <p>
23  * HttpStatusCode enum class, for status codes based on various HTTP RFCs. (see
24  * table below)
25  * </p>
26  *
27  * <table border="1" cellpadding="5">
28  * <tr>
29  * <th>Enum</th>
30  * <th>Code</th>
31  * <th>Message</th>
32  * <th>
33  * <a href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a></th>
34  * <th>
35  * <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a></th>
36  * <th>
37  * <a href="http://tools.ietf.org/html/rfc2518">RFC 2518 - WEBDAV</a></th>
38  * </tr>
39  *
40  * <tr>
41  * <td><strong><code>Informational - 1xx</code></strong></td>
42  * <td colspan="5">{@link #isInformational(int)}</td>
43  * </tr>
44  *
45  * <tr>
46  * <td>{@link #CONTINUE_100}</td>
47  * <td>100</td>
48  * <td>Continue</td>
49  * <td>&nbsp;</td>
50  * <td>
51  * <a href="http://tools.ietf.org/html/rfc2616#section-10.1.1">Sec. 10.1.1</a></td>
52  * <td>&nbsp;</td>
53  * </tr>
54  * <tr>
55  * <td>{@link #SWITCHING_PROTOCOLS_101}</td>
56  * <td>101</td>
57  * <td>Switching Protocols</td>
58  * <td>&nbsp;</td>
59  * <td>
60  * <a href="http://tools.ietf.org/html/rfc2616#section-10.1.2">Sec. 10.1.2</a></td>
61  * <td>&nbsp;</td>
62  * </tr>
63  * <tr>
64  * <td>{@link #PROCESSING_102}</td>
65  * <td>102</td>
66  * <td>Processing</td>
67  * <td>&nbsp;</td>
68  * <td>&nbsp;</td>
69  * <td>
70  * <a href="http://tools.ietf.org/html/rfc2518#section-10.1">Sec. 10.1</a></td>
71  * </tr>
72  *
73  * <tr>
74  * <td><strong><code>Success - 2xx</code></strong></td>
75  * <td colspan="5">{@link #isSuccess(int)}</td>
76  * </tr>
77  *
78  * <tr>
79  * <td>{@link #OK_200}</td>
80  * <td>200</td>
81  * <td>OK</td>
82  * <td>
83  * <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td>
84  * <td>
85  * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.1">Sec. 10.2.1</a></td>
86  * <td>&nbsp;</td>
87  * </tr>
88  * <tr>
89  * <td>{@link #CREATED_201}</td>
90  * <td>201</td>
91  * <td>Created</td>
92  * <td>
93  * <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td>
94  * <td>
95  * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.2">Sec. 10.2.2</a></td>
96  * <td>&nbsp;</td>
97  * </tr>
98  * <tr>
99  * <td>{@link #ACCEPTED_202}</td>
100  * <td>202</td>
101  * <td>Accepted</td>
102  * <td>
103  * <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td>
104  * <td>
105  * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.3">Sec. 10.2.3</a></td>
106  * <td>&nbsp;</td>
107  * </tr>
108  * <tr>
109  * <td>{@link #NON_AUTHORITATIVE_INFORMATION_203}</td>
110  * <td>203</td>
111  * <td>Non Authoritative Information</td>
112  * <td>&nbsp;</td>
113  * <td>
114  * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.4">Sec. 10.2.4</a></td>
115  * <td>&nbsp;</td>
116  * </tr>
117  * <tr>
118  * <td>{@link #NO_CONTENT_204}</td>
119  * <td>204</td>
120  * <td>No Content</td>
121  * <td>
122  * <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td>
123  * <td>
124  * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.5">Sec. 10.2.5</a></td>
125  * <td>&nbsp;</td>
126  * </tr>
127  * <tr>
128  * <td>{@link #RESET_CONTENT_205}</td>
129  * <td>205</td>
130  * <td>Reset Content</td>
131  * <td>&nbsp;</td>
132  * <td>
133  * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.6">Sec. 10.2.6</a></td>
134  * <td>&nbsp;</td>
135  * </tr>
136  * <tr>
137  * <td>{@link #PARTIAL_CONTENT_206}</td>
138  * <td>206</td>
139  * <td>Partial Content</td>
140  * <td>&nbsp;</td>
141  * <td>
142  * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.7">Sec. 10.2.7</a></td>
143  * <td>&nbsp;</td>
144  * </tr>
145  * <tr>
146  * <td>{@link #MULTI_STATUS_207}</td>
147  * <td>207</td>
148  * <td>Multi-Status</td>
149  * <td>&nbsp;</td>
150  * <td>&nbsp;</td>
151  * <td>
152  * <a href="http://tools.ietf.org/html/rfc2518#section-10.2">Sec. 10.2</a></td>
153  * </tr>
154  * <tr>
155  * <td>&nbsp;</td>
156  * <td><strike>207</strike></td>
157  * <td><strike>Partial Update OK</strike></td>
158  * <td>&nbsp;</td>
159  * <td>
160  * <a href=
161  * "http://www.w3.org/Protocols/HTTP/1.1/draft-ietf-http-v11-spec-rev-01.txt"
162  * >draft/01</a></td>
163  * <td>&nbsp;</td>
164  * </tr>
165  *
166  * <tr>
167  * <td><strong><code>Redirection - 3xx</code></strong></td>
168  * <td colspan="5">{@link #isRedirection(int)}</td>
169  * </tr>
170  *
171  * <tr>
172  * <td>{@link #MULTIPLE_CHOICES_300}</td>
173  * <td>300</td>
174  * <td>Multiple Choices</td>
175  * <td>
176  * <a href="http://tools.ietf.org/html/rfc1945#section-9.3">Sec. 9.3</a></td>
177  * <td>
178  * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.1">Sec. 10.3.1</a></td>
179  * <td>&nbsp;</td>
180  * </tr>
181  * <tr>
182  * <td>{@link #MOVED_PERMANENTLY_301}</td>
183  * <td>301</td>
184  * <td>Moved Permanently</td>
185  * <td>
186  * <a href="http://tools.ietf.org/html/rfc1945#section-9.3">Sec. 9.3</a></td>
187  * <td>
188  * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.2">Sec. 10.3.2</a></td>
189  * <td>&nbsp;</td>
190  * </tr>
191  * <tr>
192  * <td>{@link #MOVED_TEMPORARILY_302}</td>
193  * <td>302</td>
194  * <td>Moved Temporarily</td>
195  * <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>
198  * <td>&nbsp;</td>
199  * </tr>
200  * <tr>
201  * <td>{@link #FOUND_302}</td>
202  * <td>302</td>
203  * <td>Found</td>
204  * <td>(was "<code>302 Moved Temporarily</code>")</td>
205  * <td>
206  * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.3">Sec. 10.3.3</a></td>
207  * <td>&nbsp;</td>
208  * </tr>
209  * <tr>
210  * <td>{@link #SEE_OTHER_303}</td>
211  * <td>303</td>
212  * <td>See Other</td>
213  * <td>&nbsp;</td>
214  * <td>
215  * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.4">Sec. 10.3.4</a></td>
216  * <td>&nbsp;</td>
217  * </tr>
218  * <tr>
219  * <td>{@link #NOT_MODIFIED_304}</td>
220  * <td>304</td>
221  * <td>Not Modified</td>
222  * <td>
223  * <a href="http://tools.ietf.org/html/rfc1945#section-9.3">Sec. 9.3</a></td>
224  * <td>
225  * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.5">Sec. 10.3.5</a></td>
226  * <td>&nbsp;</td>
227  * </tr>
228  * <tr>
229  * <td>{@link #USE_PROXY_305}</td>
230  * <td>305</td>
231  * <td>Use Proxy</td>
232  * <td>&nbsp;</td>
233  * <td>
234  * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.6">Sec. 10.3.6</a></td>
235  * <td>&nbsp;</td>
236  * </tr>
237  * <tr>
238  * <td>&nbsp;</td>
239  * <td>306</td>
240  * <td><em>(Unused)</em></td>
241  * <td>&nbsp;</td>
242  * <td>
243  * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.7">Sec. 10.3.7</a></td>
244  * <td>&nbsp;</td>
245  * </tr>
246  * <tr>
247  * <td>{@link #TEMPORARY_REDIRECT_307}</td>
248  * <td>307</td>
249  * <td>Temporary Redirect</td>
250  * <td>&nbsp;</td>
251  * <td>
252  * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.8">Sec. 10.3.8</a></td>
253  * <td>&nbsp;</td>
254  * </tr>
255  *
256  * <tr>
257  * <td><strong><code>Client Error - 4xx</code></strong></td>
258  * <td colspan="5">{@link #isClientError(int)}</td>
259  * </tr>
260  *
261  * <tr>
262  * <td>{@link #BAD_REQUEST_400}</td>
263  * <td>400</td>
264  * <td>Bad Request</td>
265  * <td>
266  * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
267  * <td>
268  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.1">Sec. 10.4.1</a></td>
269  * <td>&nbsp;</td>
270  * </tr>
271  * <tr>
272  * <td>{@link #UNAUTHORIZED_401}</td>
273  * <td>401</td>
274  * <td>Unauthorized</td>
275  * <td>
276  * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
277  * <td>
278  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.2">Sec. 10.4.2</a></td>
279  * <td>&nbsp;</td>
280  * </tr>
281  * <tr>
282  * <td>{@link #PAYMENT_REQUIRED_402}</td>
283  * <td>402</td>
284  * <td>Payment Required</td>
285  * <td>
286  * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
287  * <td>
288  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.3">Sec. 10.4.3</a></td>
289  * <td>&nbsp;</td>
290  * </tr>
291  * <tr>
292  * <td>{@link #FORBIDDEN_403}</td>
293  * <td>403</td>
294  * <td>Forbidden</td>
295  * <td>
296  * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
297  * <td>
298  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.4">Sec. 10.4.4</a></td>
299  * <td>&nbsp;</td>
300  * </tr>
301  * <tr>
302  * <td>{@link #NOT_FOUND_404}</td>
303  * <td>404</td>
304  * <td>Not Found</td>
305  * <td>
306  * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
307  * <td>
308  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.5">Sec. 10.4.5</a></td>
309  * <td>&nbsp;</td>
310  * </tr>
311  * <tr>
312  * <td>{@link #METHOD_NOT_ALLOWED_405}</td>
313  * <td>405</td>
314  * <td>Method Not Allowed</td>
315  * <td>&nbsp;</td>
316  * <td>
317  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.6">Sec. 10.4.6</a></td>
318  * <td>&nbsp;</td>
319  * </tr>
320  * <tr>
321  * <td>{@link #NOT_ACCEPTABLE_406}</td>
322  * <td>406</td>
323  * <td>Not Acceptable</td>
324  * <td>&nbsp;</td>
325  * <td>
326  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.7">Sec. 10.4.7</a></td>
327  * <td>&nbsp;</td>
328  * </tr>
329  * <tr>
330  * <td>{@link #PROXY_AUTHENTICATION_REQUIRED_407}</td>
331  * <td>407</td>
332  * <td>Proxy Authentication Required</td>
333  * <td>&nbsp;</td>
334  * <td>
335  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.8">Sec. 10.4.8</a></td>
336  * <td>&nbsp;</td>
337  * </tr>
338  * <tr>
339  * <td>{@link #REQUEST_TIMEOUT_408}</td>
340  * <td>408</td>
341  * <td>Request Timeout</td>
342  * <td>&nbsp;</td>
343  * <td>
344  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.9">Sec. 10.4.9</a></td>
345  * <td>&nbsp;</td>
346  * </tr>
347  * <tr>
348  * <td>{@link #CONFLICT_409}</td>
349  * <td>409</td>
350  * <td>Conflict</td>
351  * <td>&nbsp;</td>
352  * <td>
353  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.10">Sec. 10.4.10</a>
354  * </td>
355  * <td>&nbsp;</td>
356  * </tr>
357  * <tr>
358  * <td>{@link #GONE_410}</td>
359  * <td>410</td>
360  * <td>Gone</td>
361  * <td>&nbsp;</td>
362  * <td>
363  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.11">Sec. 10.4.11</a>
364  * </td>
365  * <td>&nbsp;</td>
366  * </tr>
367  * <tr>
368  * <td>{@link #LENGTH_REQUIRED_411}</td>
369  * <td>411</td>
370  * <td>Length Required</td>
371  * <td>&nbsp;</td>
372  * <td>
373  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.12">Sec. 10.4.12</a>
374  * </td>
375  * <td>&nbsp;</td>
376  * </tr>
377  * <tr>
378  * <td>{@link #PRECONDITION_FAILED_412}</td>
379  * <td>412</td>
380  * <td>Precondition Failed</td>
381  * <td>&nbsp;</td>
382  * <td>
383  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.13">Sec. 10.4.13</a>
384  * </td>
385  * <td>&nbsp;</td>
386  * </tr>
387  * <tr>
388  * <td>{@link #REQUEST_ENTITY_TOO_LARGE_413}</td>
389  * <td>413</td>
390  * <td>Request Entity Too Large</td>
391  * <td>&nbsp;</td>
392  * <td>
393  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.14">Sec. 10.4.14</a>
394  * </td>
395  * <td>&nbsp;</td>
396  * </tr>
397  * <tr>
398  * <td>{@link #REQUEST_URI_TOO_LONG_414}</td>
399  * <td>414</td>
400  * <td>Request-URI Too Long</td>
401  * <td>&nbsp;</td>
402  * <td>
403  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.15">Sec. 10.4.15</a>
404  * </td>
405  * <td>&nbsp;</td>
406  * </tr>
407  * <tr>
408  * <td>{@link #UNSUPPORTED_MEDIA_TYPE_415}</td>
409  * <td>415</td>
410  * <td>Unsupported Media Type</td>
411  * <td>&nbsp;</td>
412  * <td>
413  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.16">Sec. 10.4.16</a>
414  * </td>
415  * <td>&nbsp;</td>
416  * </tr>
417  * <tr>
418  * <td>{@link #REQUESTED_RANGE_NOT_SATISFIABLE_416}</td>
419  * <td>416</td>
420  * <td>Requested Range Not Satisfiable</td>
421  * <td>&nbsp;</td>
422  * <td>
423  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.17">Sec. 10.4.17</a>
424  * </td>
425  * <td>&nbsp;</td>
426  * </tr>
427  * <tr>
428  * <td>{@link #EXPECTATION_FAILED_417}</td>
429  * <td>417</td>
430  * <td>Expectation Failed</td>
431  * <td>&nbsp;</td>
432  * <td>
433  * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.18">Sec. 10.4.18</a>
434  * </td>
435  * <td>&nbsp;</td>
436  * </tr>
437  * <tr>
438  * <td>&nbsp;</td>
439  * <td><strike>418</strike></td>
440  * <td><strike>Reauthentication Required</strike></td>
441  * <td>&nbsp;</td>
442  * <td>
443  * <a href=
444  * "http://tools.ietf.org/html/draft-ietf-http-v11-spec-rev-01#section-10.4.19"
445  * >draft/01</a></td>
446  * <td>&nbsp;</td>
447  * </tr>
448  * <tr>
449  * <td>&nbsp;</td>
450  * <td><strike>418</strike></td>
451  * <td><strike>Unprocessable Entity</strike></td>
452  * <td>&nbsp;</td>
453  * <td>&nbsp;</td>
454  * <td>
455  * <a href=
456  * "http://tools.ietf.org/html/draft-ietf-webdav-protocol-05#section-10.3"
457  * >draft/05</a></td>
458  * </tr>
459  * <tr>
460  * <td>&nbsp;</td>
461  * <td><strike>419</strike></td>
462  * <td><strike>Proxy Reauthentication Required</stike></td>
463  * <td>&nbsp;</td>
464  * <td>
465  * <a href=
466  * "http://tools.ietf.org/html/draft-ietf-http-v11-spec-rev-01#section-10.4.20"
467  * >draft/01</a></td>
468  * <td>&nbsp;</td>
469  * </tr>
470  * <tr>
471  * <td>&nbsp;</td>
472  * <td><strike>419</strike></td>
473  * <td><strike>Insufficient Space on Resource</stike></td>
474  * <td>&nbsp;</td>
475  * <td>&nbsp;</td>
476  * <td>
477  * <a href=
478  * "http://tools.ietf.org/html/draft-ietf-webdav-protocol-05#section-10.4"
479  * >draft/05</a></td>
480  * </tr>
481  * <tr>
482  * <td>&nbsp;</td>
483  * <td><strike>420</strike></td>
484  * <td><strike>Method Failure</strike></td>
485  * <td>&nbsp;</td>
486  * <td>&nbsp;</td>
487  * <td>
488  * <a href=
489  * "http://tools.ietf.org/html/draft-ietf-webdav-protocol-05#section-10.5"
490  * >draft/05</a></td>
491  * </tr>
492  * <tr>
493  * <td>&nbsp;</td>
494  * <td>421</td>
495  * <td><em>(Unused)</em></td>
496  * <td>&nbsp;</td>
497  * <td>&nbsp;</td>
498  * <td>&nbsp;</td>
499  * </tr>
500  * <tr>
501  * <td>{@link #UNPROCESSABLE_ENTITY_422}</td>
502  * <td>422</td>
503  * <td>Unprocessable Entity</td>
504  * <td>&nbsp;</td>
505  * <td>&nbsp;</td>
506  * <td>
507  * <a href="http://tools.ietf.org/html/rfc2518#section-10.3">Sec. 10.3</a></td>
508  * </tr>
509  * <tr>
510  * <td>{@link #LOCKED_423}</td>
511  * <td>423</td>
512  * <td>Locked</td>
513  * <td>&nbsp;</td>
514  * <td>&nbsp;</td>
515  * <td>
516  * <a href="http://tools.ietf.org/html/rfc2518#section-10.4">Sec. 10.4</a></td>
517  * </tr>
518  * <tr>
519  * <td>{@link #FAILED_DEPENDENCY_424}</td>
520  * <td>424</td>
521  * <td>Failed Dependency</td>
522  * <td>&nbsp;</td>
523  * <td>&nbsp;</td>
524  * <td>
525  * <a href="http://tools.ietf.org/html/rfc2518#section-10.5">Sec. 10.5</a></td>
526  * </tr>
527  *
528  * <tr>
529  * <td><strong><code>Server Error - 5xx</code></strong></td>
530  * <td colspan="5">{@link #isServerError(int)}</td>
531  * </tr>
532  *
533  * <tr>
534  * <td>{@link #INTERNAL_SERVER_ERROR_500}</td>
535  * <td>500</td>
536  * <td>Internal Server Error</td>
537  * <td>
538  * <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td>
539  * <td>
540  * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.1">Sec. 10.5.1</a></td>
541  * <td>&nbsp;</td>
542  * </tr>
543  * <tr>
544  * <td>{@link #NOT_IMPLEMENTED_501}</td>
545  * <td>501</td>
546  * <td>Not Implemented</td>
547  * <td>
548  * <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td>
549  * <td>
550  * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.2">Sec. 10.5.2</a></td>
551  * <td>&nbsp;</td>
552  * </tr>
553  * <tr>
554  * <td>{@link #BAD_GATEWAY_502}</td>
555  * <td>502</td>
556  * <td>Bad Gateway</td>
557  * <td>
558  * <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td>
559  * <td>
560  * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.3">Sec. 10.5.3</a></td>
561  * <td>&nbsp;</td>
562  * </tr>
563  * <tr>
564  * <td>{@link #SERVICE_UNAVAILABLE_503}</td>
565  * <td>503</td>
566  * <td>Service Unavailable</td>
567  * <td>
568  * <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td>
569  * <td>
570  * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.4">Sec. 10.5.4</a></td>
571  * <td>&nbsp;</td>
572  * </tr>
573  * <tr>
574  * <td>{@link #GATEWAY_TIMEOUT_504}</td>
575  * <td>504</td>
576  * <td>Gateway Timeout</td>
577  * <td>&nbsp;</td>
578  * <td>
579  * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.5">Sec. 10.5.5</a></td>
580  * <td>&nbsp;</td>
581  * </tr>
582  * <tr>
583  * <td>{@link #HTTP_VERSION_NOT_SUPPORTED_505}</td>
584  * <td>505</td>
585  * <td>HTTP Version Not Supported</td>
586  * <td>&nbsp;</td>
587  * <td>
588  * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.6">Sec. 10.5.6</a></td>
589  * <td>&nbsp;</td>
590  * </tr>
591  * <tr>
592  * <td>&nbsp;</td>
593  * <td>506</td>
594  * <td><em>(Unused)</em></td>
595  * <td>&nbsp;</td>
596  * <td>&nbsp;</td>
597  * <td>&nbsp;</td>
598  * </tr>
599  * <tr>
600  * <td>{@link #INSUFFICIENT_STORAGE_507}</td>
601  * <td>507</td>
602  * <td>Insufficient Storage</td>
603  * <td>&nbsp;</td>
604  * <td>&nbsp;</td>
605  * <td>
606  * <a href="http://tools.ietf.org/html/rfc2518#section-10.6">Sec. 10.6</a></td>
607  * </tr>
608  *
609  * </table>
610  *
611  * @version $Id$
612  */
613 public class HttpStatus
614 {
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;
618
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;
627
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;
636
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;
658
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;
666
667     public static final int MAX_CODE = 507;
668
669
670     private static final Code[] codeMap = new Code[MAX_CODE+1];
671
672     static
673     {
674         for (Code code : Code.values())
675         {
676             codeMap[code._code] = code;
677         }
678     }
679
680
681     public enum Code
682     {
683         /*
684          * --------------------------------------------------------------------
685          * Informational messages in 1xx series. As defined by ... RFC 1945 -
686          * HTTP/1.0 RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
687          */
688
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"),
695
696         /*
697          * --------------------------------------------------------------------
698          * Success messages in 2xx series. As defined by ... RFC 1945 - HTTP/1.0
699          * RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
700          */
701
702         /** <code>200 OK</code> */
703         OK(OK_200, "OK"),
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"),
718
719         /*
720          * --------------------------------------------------------------------
721          * Redirection messages in 3xx series. As defined by ... RFC 1945 -
722          * HTTP/1.0 RFC 2616 - HTTP/1.1
723          */
724
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"),
741
742         /*
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
746          */
747
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"),
790
791         /*
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
795          */
796
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");
811
812         private final int _code;
813         private final String _message;
814
815         private Code(int code, String message)
816         {
817             this._code = code;
818             _message=message;
819         }
820
821         public int getCode()
822         {
823             return _code;
824         }
825
826         public String getMessage()
827         {
828             return _message;
829         }
830
831
832         public boolean equals(int code)
833         {
834             return (this._code == code);
835         }
836
837         @Override
838         public String toString()
839         {
840             return String.format("[%03d %s]",this._code,this.getMessage());
841         }
842
843         /**
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 -
848          * HTTP/1.1</a>.
849          *
850          * @return true if within range of codes that belongs to
851          *         <code>Informational</code> messages.
852          */
853         public boolean isInformational()
854         {
855             return HttpStatus.isInformational(this._code);
856         }
857
858         /**
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 -
863          * HTTP/1.1</a>.
864          *
865          * @return true if within range of codes that belongs to
866          *         <code>Success</code> messages.
867          */
868         public boolean isSuccess()
869         {
870             return HttpStatus.isSuccess(this._code);
871         }
872
873         /**
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 -
878          * HTTP/1.1</a>.
879          *
880          * @return true if within range of codes that belongs to
881          *         <code>Redirection</code> messages.
882          */
883         public boolean isRedirection()
884         {
885             return HttpStatus.isRedirection(this._code);
886         }
887
888         /**
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 -
893          * HTTP/1.1</a>.
894          *
895          * @return true if within range of codes that belongs to
896          *         <code>Client Error</code> messages.
897          */
898         public boolean isClientError()
899         {
900             return HttpStatus.isClientError(this._code);
901         }
902
903         /**
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 -
908          * HTTP/1.1</a>.
909          *
910          * @return true if within range of codes that belongs to
911          *         <code>Server Error</code> messages.
912          */
913         public boolean isServerError()
914         {
915             return HttpStatus.isServerError(this._code);
916         }
917     }
918
919
920     /**
921      * Get the HttpStatusCode for a specific code
922      *
923      * @param code
924      *            the code to lookup.
925      * @return the {@link HttpStatus} if found, or null if not found.
926      */
927     public static Code getCode(int code)
928     {
929         if (code <= MAX_CODE)
930         {
931             return codeMap[code];
932         }
933         return null;
934     }
935
936     /**
937      * Get the status message for a specific code.
938      *
939      * @param 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.
943      */
944     public static String getMessage(int code)
945     {
946         Code codeEnum = getCode(code);
947         if (codeEnum != null)
948         {
949             return codeEnum.getMessage();
950         }
951         else
952         {
953             return Integer.toString(code);
954         }
955     }
956
957     /**
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>.
962      *
963      * @param code
964      *            the code to test.
965      * @return true if within range of codes that belongs to
966      *         <code>Informational</code> messages.
967      */
968     public static boolean isInformational(int code)
969     {
970         return ((100 <= code) && (code <= 199));
971     }
972
973     /**
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>.
978      *
979      * @param code
980      *            the code to test.
981      * @return true if within range of codes that belongs to
982      *         <code>Success</code> messages.
983      */
984     public static boolean isSuccess(int code)
985     {
986         return ((200 <= code) && (code <= 299));
987     }
988
989     /**
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>.
994      *
995      * @param code
996      *            the code to test.
997      * @return true if within range of codes that belongs to
998      *         <code>Redirection</code> messages.
999      */
1000     public static boolean isRedirection(int code)
1001     {
1002         return ((300 <= code) && (code <= 399));
1003     }
1004
1005     /**
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>.
1010      *
1011      * @param code
1012      *            the code to test.
1013      * @return true if within range of codes that belongs to
1014      *         <code>Client Error</code> messages.
1015      */
1016     public static boolean isClientError(int code)
1017     {
1018         return ((400 <= code) && (code <= 499));
1019     }
1020
1021     /**
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>.
1026      *
1027      * @param code
1028      *            the code to test.
1029      * @return true if within range of codes that belongs to
1030      *         <code>Server Error</code> messages.
1031      */
1032     public static boolean isServerError(int code)
1033     {
1034         return ((500 <= code) && (code <= 599));
1035     }
1036 }