1 //
2 // ========================================================================
3 // Copyright (c) 1995-2013 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> </td>
50 * <td>
51 * <a href="http://tools.ietf.org/html/rfc2616#section-10.1.1">Sec. 10.1.1</a></td>
52 * <td> </td>
53 * </tr>
54 * <tr>
55 * <td>{@link #SWITCHING_PROTOCOLS_101}</td>
56 * <td>101</td>
57 * <td>Switching Protocols</td>
58 * <td> </td>
59 * <td>
60 * <a href="http://tools.ietf.org/html/rfc2616#section-10.1.2">Sec. 10.1.2</a></td>
61 * <td> </td>
62 * </tr>
63 * <tr>
64 * <td>{@link #PROCESSING_102}</td>
65 * <td>102</td>
66 * <td>Processing</td>
67 * <td> </td>
68 * <td> </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> </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> </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> </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> </td>
113 * <td>
114 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.4">Sec. 10.2.4</a></td>
115 * <td> </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> </td>
126 * </tr>
127 * <tr>
128 * <td>{@link #RESET_CONTENT_205}</td>
129 * <td>205</td>
130 * <td>Reset Content</td>
131 * <td> </td>
132 * <td>
133 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.6">Sec. 10.2.6</a></td>
134 * <td> </td>
135 * </tr>
136 * <tr>
137 * <td>{@link #PARTIAL_CONTENT_206}</td>
138 * <td>206</td>
139 * <td>Partial Content</td>
140 * <td> </td>
141 * <td>
142 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.7">Sec. 10.2.7</a></td>
143 * <td> </td>
144 * </tr>
145 * <tr>
146 * <td>{@link #MULTI_STATUS_207}</td>
147 * <td>207</td>
148 * <td>Multi-Status</td>
149 * <td> </td>
150 * <td> </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> </td>
156 * <td><strike>207</strike></td>
157 * <td><strike>Partial Update OK</strike></td>
158 * <td> </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> </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> </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> </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> </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> </td>
208 * </tr>
209 * <tr>
210 * <td>{@link #SEE_OTHER_303}</td>
211 * <td>303</td>
212 * <td>See Other</td>
213 * <td> </td>
214 * <td>
215 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.4">Sec. 10.3.4</a></td>
216 * <td> </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> </td>
227 * </tr>
228 * <tr>
229 * <td>{@link #USE_PROXY_305}</td>
230 * <td>305</td>
231 * <td>Use Proxy</td>
232 * <td> </td>
233 * <td>
234 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.6">Sec. 10.3.6</a></td>
235 * <td> </td>
236 * </tr>
237 * <tr>
238 * <td> </td>
239 * <td>306</td>
240 * <td><em>(Unused)</em></td>
241 * <td> </td>
242 * <td>
243 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.7">Sec. 10.3.7</a></td>
244 * <td> </td>
245 * </tr>
246 * <tr>
247 * <td>{@link #TEMPORARY_REDIRECT_307}</td>
248 * <td>307</td>
249 * <td>Temporary Redirect</td>
250 * <td> </td>
251 * <td>
252 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.8">Sec. 10.3.8</a></td>
253 * <td> </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> </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> </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> </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> </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> </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> </td>
316 * <td>
317 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.6">Sec. 10.4.6</a></td>
318 * <td> </td>
319 * </tr>
320 * <tr>
321 * <td>{@link #NOT_ACCEPTABLE_406}</td>
322 * <td>406</td>
323 * <td>Not Acceptable</td>
324 * <td> </td>
325 * <td>
326 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.7">Sec. 10.4.7</a></td>
327 * <td> </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> </td>
334 * <td>
335 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.8">Sec. 10.4.8</a></td>
336 * <td> </td>
337 * </tr>
338 * <tr>
339 * <td>{@link #REQUEST_TIMEOUT_408}</td>
340 * <td>408</td>
341 * <td>Request Timeout</td>
342 * <td> </td>
343 * <td>
344 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.9">Sec. 10.4.9</a></td>
345 * <td> </td>
346 * </tr>
347 * <tr>
348 * <td>{@link #CONFLICT_409}</td>
349 * <td>409</td>
350 * <td>Conflict</td>
351 * <td> </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> </td>
356 * </tr>
357 * <tr>
358 * <td>{@link #GONE_410}</td>
359 * <td>410</td>
360 * <td>Gone</td>
361 * <td> </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> </td>
366 * </tr>
367 * <tr>
368 * <td>{@link #LENGTH_REQUIRED_411}</td>
369 * <td>411</td>
370 * <td>Length Required</td>
371 * <td> </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> </td>
376 * </tr>
377 * <tr>
378 * <td>{@link #PRECONDITION_FAILED_412}</td>
379 * <td>412</td>
380 * <td>Precondition Failed</td>
381 * <td> </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> </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> </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> </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> </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> </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> </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> </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> </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> </td>
426 * </tr>
427 * <tr>
428 * <td>{@link #EXPECTATION_FAILED_417}</td>
429 * <td>417</td>
430 * <td>Expectation Failed</td>
431 * <td> </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> </td>
436 * </tr>
437 * <tr>
438 * <td> </td>
439 * <td><strike>418</strike></td>
440 * <td><strike>Reauthentication Required</strike></td>
441 * <td> </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> </td>
447 * </tr>
448 * <tr>
449 * <td> </td>
450 * <td><strike>418</strike></td>
451 * <td><strike>Unprocessable Entity</strike></td>
452 * <td> </td>
453 * <td> </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> </td>
461 * <td><strike>419</strike></td>
462 * <td><strike>Proxy Reauthentication Required</stike></td>
463 * <td> </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> </td>
469 * </tr>
470 * <tr>
471 * <td> </td>
472 * <td><strike>419</strike></td>
473 * <td><strike>Insufficient Space on Resource</stike></td>
474 * <td> </td>
475 * <td> </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> </td>
483 * <td><strike>420</strike></td>
484 * <td><strike>Method Failure</strike></td>
485 * <td> </td>
486 * <td> </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> </td>
494 * <td>421</td>
495 * <td><em>(Unused)</em></td>
496 * <td> </td>
497 * <td> </td>
498 * <td> </td>
499 * </tr>
500 * <tr>
501 * <td>{@link #UNPROCESSABLE_ENTITY_422}</td>
502 * <td>422</td>
503 * <td>Unprocessable Entity</td>
504 * <td> </td>
505 * <td> </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> </td>
514 * <td> </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> </td>
523 * <td> </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> </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> </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> </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> </td>
572 * </tr>
573 * <tr>
574 * <td>{@link #GATEWAY_TIMEOUT_504}</td>
575 * <td>504</td>
576 * <td>Gateway Timeout</td>
577 * <td> </td>
578 * <td>
579 * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.5">Sec. 10.5.5</a></td>
580 * <td> </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> </td>
587 * <td>
588 * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.6">Sec. 10.5.6</a></td>
589 * <td> </td>
590 * </tr>
591 * <tr>
592 * <td> </td>
593 * <td>506</td>
594 * <td><em>(Unused)</em></td>
595 * <td> </td>
596 * <td> </td>
597 * <td> </td>
598 * </tr>
599 * <tr>
600 * <td>{@link #INSUFFICIENT_STORAGE_507}</td>
601 * <td>507</td>
602 * <td>Insufficient Storage</td>
603 * <td> </td>
604 * <td> </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 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;
619
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;
628
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;
637
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;
659
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;
667
668 public static final int MAX_CODE = 507;
669
670
671 private static final Code[] codeMap = new Code[MAX_CODE+1];
672
673 static
674 {
675 for (Code code : Code.values())
676 {
677 codeMap[code._code] = code;
678 }
679 }
680
681
682 public enum Code
683 {
684 /*
685 * --------------------------------------------------------------------
686 * Informational messages in 1xx series. As defined by ... RFC 1945 -
687 * HTTP/1.0 RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
688 */
689
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"),
696
697 /*
698 * --------------------------------------------------------------------
699 * Success messages in 2xx series. As defined by ... RFC 1945 - HTTP/1.0
700 * RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
701 */
702
703 /** <code>200 OK</code> */
704 OK(OK_200, "OK"),
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"),
719
720 /*
721 * --------------------------------------------------------------------
722 * Redirection messages in 3xx series. As defined by ... RFC 1945 -
723 * HTTP/1.0 RFC 2616 - HTTP/1.1
724 */
725
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"),
742
743 /*
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
747 */
748
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"),
791
792 /*
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
796 */
797
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");
812
813 private final int _code;
814 private final String _message;
815
816 private Code(int code, String message)
817 {
818 this._code = code;
819 _message=message;
820 }
821
822 public int getCode()
823 {
824 return _code;
825 }
826
827 public String getMessage()
828 {
829 return _message;
830 }
831
832
833 public boolean equals(int code)
834 {
835 return (this._code == code);
836 }
837
838 @Override
839 public String toString()
840 {
841 return String.format("[%03d %s]",this._code,this.getMessage());
842 }
843
844 /**
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 -
849 * HTTP/1.1</a>.
850 *
851 * @return true if within range of codes that belongs to
852 * <code>Informational</code> messages.
853 */
854 public boolean isInformational()
855 {
856 return HttpStatus.isInformational(this._code);
857 }
858
859 /**
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 -
864 * HTTP/1.1</a>.
865 *
866 * @return true if within range of codes that belongs to
867 * <code>Success</code> messages.
868 */
869 public boolean isSuccess()
870 {
871 return HttpStatus.isSuccess(this._code);
872 }
873
874 /**
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 -
879 * HTTP/1.1</a>.
880 *
881 * @return true if within range of codes that belongs to
882 * <code>Redirection</code> messages.
883 */
884 public boolean isRedirection()
885 {
886 return HttpStatus.isRedirection(this._code);
887 }
888
889 /**
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 -
894 * HTTP/1.1</a>.
895 *
896 * @return true if within range of codes that belongs to
897 * <code>Client Error</code> messages.
898 */
899 public boolean isClientError()
900 {
901 return HttpStatus.isClientError(this._code);
902 }
903
904 /**
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 -
909 * HTTP/1.1</a>.
910 *
911 * @return true if within range of codes that belongs to
912 * <code>Server Error</code> messages.
913 */
914 public boolean isServerError()
915 {
916 return HttpStatus.isServerError(this._code);
917 }
918 }
919
920
921 /**
922 * Get the HttpStatusCode for a specific code
923 *
924 * @param code
925 * the code to lookup.
926 * @return the {@link HttpStatus} if found, or null if not found.
927 */
928 public static Code getCode(int code)
929 {
930 if (code <= MAX_CODE)
931 {
932 return codeMap[code];
933 }
934 return null;
935 }
936
937 /**
938 * Get the status message for a specific code.
939 *
940 * @param 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.
944 */
945 public static String getMessage(int code)
946 {
947 Code codeEnum = getCode(code);
948 if (codeEnum != null)
949 {
950 return codeEnum.getMessage();
951 }
952 else
953 {
954 return Integer.toString(code);
955 }
956 }
957
958 /**
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>.
963 *
964 * @param code
965 * the code to test.
966 * @return true if within range of codes that belongs to
967 * <code>Informational</code> messages.
968 */
969 public static boolean isInformational(int code)
970 {
971 return ((100 <= code) && (code <= 199));
972 }
973
974 /**
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>.
979 *
980 * @param code
981 * the code to test.
982 * @return true if within range of codes that belongs to
983 * <code>Success</code> messages.
984 */
985 public static boolean isSuccess(int code)
986 {
987 return ((200 <= code) && (code <= 299));
988 }
989
990 /**
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>.
995 *
996 * @param code
997 * the code to test.
998 * @return true if within range of codes that belongs to
999 * <code>Redirection</code> messages.
1000 */
1001 public static boolean isRedirection(int code)
1002 {
1003 return ((300 <= code) && (code <= 399));
1004 }
1005
1006 /**
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>.
1011 *
1012 * @param code
1013 * the code to test.
1014 * @return true if within range of codes that belongs to
1015 * <code>Client Error</code> messages.
1016 */
1017 public static boolean isClientError(int code)
1018 {
1019 return ((400 <= code) && (code <= 499));
1020 }
1021
1022 /**
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>.
1027 *
1028 * @param code
1029 * the code to test.
1030 * @return true if within range of codes that belongs to
1031 * <code>Server Error</code> messages.
1032 */
1033 public static boolean isServerError(int code)
1034 {
1035 return ((500 <= code) && (code <= 599));
1036 }
1037 }