1 // ======================================================================== 2 // Copyright (c) 2004-2009 Mort Bay Consulting Pty. Ltd. 3 // ------------------------------------------------------------------------ 4 // All rights reserved. This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v1.0 6 // and Apache License v2.0 which accompanies this distribution. 7 // The Eclipse Public License is available at 8 // http://www.eclipse.org/legal/epl-v10.html 9 // The Apache License v2.0 is available at 10 // http://www.opensource.org/licenses/apache2.0.php 11 // You may elect to redistribute this code under either of these licenses. 12 // ======================================================================== 13 14 package org.eclipse.jetty.http; 15 16 /** 17 * <p> 18 * HttpStatusCode enum class, for status codes based on various HTTP RFCs. (see 19 * table below) 20 * </p> 21 * 22 * <table border="1" cellpadding="5"> 23 * <tr> 24 * <th>Enum</th> 25 * <th>Code</th> 26 * <th>Message</th> 27 * <th> 28 * <a href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a></th> 29 * <th> 30 * <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a></th> 31 * <th> 32 * <a href="http://tools.ietf.org/html/rfc2518">RFC 2518 - WEBDAV</a></th> 33 * </tr> 34 * 35 * <tr> 36 * <td><strong><code>Informational - 1xx</code></strong></td> 37 * <td colspan="5">{@link #isInformational(int)}</td> 38 * </tr> 39 * 40 * <tr> 41 * <td>{@link #CONTINUE_100}</td> 42 * <td>100</td> 43 * <td>Continue</td> 44 * <td> </td> 45 * <td> 46 * <a href="http://tools.ietf.org/html/rfc2616#section-10.1.1">Sec. 10.1.1</a></td> 47 * <td> </td> 48 * </tr> 49 * <tr> 50 * <td>{@link #SWITCHING_PROTOCOLS_101}</td> 51 * <td>101</td> 52 * <td>Switching Protocols</td> 53 * <td> </td> 54 * <td> 55 * <a href="http://tools.ietf.org/html/rfc2616#section-10.1.2">Sec. 10.1.2</a></td> 56 * <td> </td> 57 * </tr> 58 * <tr> 59 * <td>{@link #PROCESSING_102}</td> 60 * <td>102</td> 61 * <td>Processing</td> 62 * <td> </td> 63 * <td> </td> 64 * <td> 65 * <a href="http://tools.ietf.org/html/rfc2518#section-10.1">Sec. 10.1</a></td> 66 * </tr> 67 * 68 * <tr> 69 * <td><strong><code>Success - 2xx</code></strong></td> 70 * <td colspan="5">{@link #isSuccess(int)}</td> 71 * </tr> 72 * 73 * <tr> 74 * <td>{@link #OK_200}</td> 75 * <td>200</td> 76 * <td>OK</td> 77 * <td> 78 * <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td> 79 * <td> 80 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.1">Sec. 10.2.1</a></td> 81 * <td> </td> 82 * </tr> 83 * <tr> 84 * <td>{@link #CREATED_201}</td> 85 * <td>201</td> 86 * <td>Created</td> 87 * <td> 88 * <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td> 89 * <td> 90 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.2">Sec. 10.2.2</a></td> 91 * <td> </td> 92 * </tr> 93 * <tr> 94 * <td>{@link #ACCEPTED_202}</td> 95 * <td>202</td> 96 * <td>Accepted</td> 97 * <td> 98 * <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td> 99 * <td> 100 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.3">Sec. 10.2.3</a></td> 101 * <td> </td> 102 * </tr> 103 * <tr> 104 * <td>{@link #NON_AUTHORITATIVE_INFORMATION_203}</td> 105 * <td>203</td> 106 * <td>Non Authoritative Information</td> 107 * <td> </td> 108 * <td> 109 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.4">Sec. 10.2.4</a></td> 110 * <td> </td> 111 * </tr> 112 * <tr> 113 * <td>{@link #NO_CONTENT_204}</td> 114 * <td>204</td> 115 * <td>No Content</td> 116 * <td> 117 * <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td> 118 * <td> 119 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.5">Sec. 10.2.5</a></td> 120 * <td> </td> 121 * </tr> 122 * <tr> 123 * <td>{@link #RESET_CONTENT_205}</td> 124 * <td>205</td> 125 * <td>Reset Content</td> 126 * <td> </td> 127 * <td> 128 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.6">Sec. 10.2.6</a></td> 129 * <td> </td> 130 * </tr> 131 * <tr> 132 * <td>{@link #PARTIAL_CONTENT_206}</td> 133 * <td>206</td> 134 * <td>Partial Content</td> 135 * <td> </td> 136 * <td> 137 * <a href="http://tools.ietf.org/html/rfc2616#section-10.2.7">Sec. 10.2.7</a></td> 138 * <td> </td> 139 * </tr> 140 * <tr> 141 * <td>{@link #MULTI_STATUS_207}</td> 142 * <td>207</td> 143 * <td>Multi-Status</td> 144 * <td> </td> 145 * <td> </td> 146 * <td> 147 * <a href="http://tools.ietf.org/html/rfc2518#section-10.2">Sec. 10.2</a></td> 148 * </tr> 149 * <tr> 150 * <td> </td> 151 * <td><strike>207</strike></td> 152 * <td><strike>Partial Update OK</strike></td> 153 * <td> </td> 154 * <td> 155 * <a href= 156 * "http://www.w3.org/Protocols/HTTP/1.1/draft-ietf-http-v11-spec-rev-01.txt" 157 * >draft/01</a></td> 158 * <td> </td> 159 * </tr> 160 * 161 * <tr> 162 * <td><strong><code>Redirection - 3xx</code></strong></td> 163 * <td colspan="5">{@link #isRedirection(int)}</td> 164 * </tr> 165 * 166 * <tr> 167 * <td>{@link #MULTIPLE_CHOICES_300}</td> 168 * <td>300</td> 169 * <td>Multiple Choices</td> 170 * <td> 171 * <a href="http://tools.ietf.org/html/rfc1945#section-9.3">Sec. 9.3</a></td> 172 * <td> 173 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.1">Sec. 10.3.1</a></td> 174 * <td> </td> 175 * </tr> 176 * <tr> 177 * <td>{@link #MOVED_PERMANENTLY_301}</td> 178 * <td>301</td> 179 * <td>Moved Permanently</td> 180 * <td> 181 * <a href="http://tools.ietf.org/html/rfc1945#section-9.3">Sec. 9.3</a></td> 182 * <td> 183 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.2">Sec. 10.3.2</a></td> 184 * <td> </td> 185 * </tr> 186 * <tr> 187 * <td>{@link #MOVED_TEMPORARILY_302}</td> 188 * <td>302</td> 189 * <td>Moved Temporarily</td> 190 * <td> 191 * <a href="http://tools.ietf.org/html/rfc1945#section-9.3">Sec. 9.3</a></td> 192 * <td>(now "<code>302 Found</code>")</td> 193 * <td> </td> 194 * </tr> 195 * <tr> 196 * <td>{@link #FOUND_302}</td> 197 * <td>302</td> 198 * <td>Found</td> 199 * <td>(was "<code>302 Moved Temporarily</code>")</td> 200 * <td> 201 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.3">Sec. 10.3.3</a></td> 202 * <td> </td> 203 * </tr> 204 * <tr> 205 * <td>{@link #SEE_OTHER_303}</td> 206 * <td>303</td> 207 * <td>See Other</td> 208 * <td> </td> 209 * <td> 210 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.4">Sec. 10.3.4</a></td> 211 * <td> </td> 212 * </tr> 213 * <tr> 214 * <td>{@link #NOT_MODIFIED_304}</td> 215 * <td>304</td> 216 * <td>Not Modified</td> 217 * <td> 218 * <a href="http://tools.ietf.org/html/rfc1945#section-9.3">Sec. 9.3</a></td> 219 * <td> 220 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.5">Sec. 10.3.5</a></td> 221 * <td> </td> 222 * </tr> 223 * <tr> 224 * <td>{@link #USE_PROXY_305}</td> 225 * <td>305</td> 226 * <td>Use Proxy</td> 227 * <td> </td> 228 * <td> 229 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.6">Sec. 10.3.6</a></td> 230 * <td> </td> 231 * </tr> 232 * <tr> 233 * <td> </td> 234 * <td>306</td> 235 * <td><em>(Unused)</em></td> 236 * <td> </td> 237 * <td> 238 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.7">Sec. 10.3.7</a></td> 239 * <td> </td> 240 * </tr> 241 * <tr> 242 * <td>{@link #TEMPORARY_REDIRECT_307}</td> 243 * <td>307</td> 244 * <td>Temporary Redirect</td> 245 * <td> </td> 246 * <td> 247 * <a href="http://tools.ietf.org/html/rfc2616#section-10.3.8">Sec. 10.3.8</a></td> 248 * <td> </td> 249 * </tr> 250 * 251 * <tr> 252 * <td><strong><code>Client Error - 4xx</code></strong></td> 253 * <td colspan="5">{@link #isClientError(int)}</td> 254 * </tr> 255 * 256 * <tr> 257 * <td>{@link #BAD_REQUEST_400}</td> 258 * <td>400</td> 259 * <td>Bad Request</td> 260 * <td> 261 * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td> 262 * <td> 263 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.1">Sec. 10.4.1</a></td> 264 * <td> </td> 265 * </tr> 266 * <tr> 267 * <td>{@link #UNAUTHORIZED_401}</td> 268 * <td>401</td> 269 * <td>Unauthorized</td> 270 * <td> 271 * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td> 272 * <td> 273 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.2">Sec. 10.4.2</a></td> 274 * <td> </td> 275 * </tr> 276 * <tr> 277 * <td>{@link #PAYMENT_REQUIRED_402}</td> 278 * <td>402</td> 279 * <td>Payment Required</td> 280 * <td> 281 * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td> 282 * <td> 283 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.3">Sec. 10.4.3</a></td> 284 * <td> </td> 285 * </tr> 286 * <tr> 287 * <td>{@link #FORBIDDEN_403}</td> 288 * <td>403</td> 289 * <td>Forbidden</td> 290 * <td> 291 * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td> 292 * <td> 293 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.4">Sec. 10.4.4</a></td> 294 * <td> </td> 295 * </tr> 296 * <tr> 297 * <td>{@link #NOT_FOUND_404}</td> 298 * <td>404</td> 299 * <td>Not Found</td> 300 * <td> 301 * <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td> 302 * <td> 303 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.5">Sec. 10.4.5</a></td> 304 * <td> </td> 305 * </tr> 306 * <tr> 307 * <td>{@link #METHOD_NOT_ALLOWED_405}</td> 308 * <td>405</td> 309 * <td>Method Not Allowed</td> 310 * <td> </td> 311 * <td> 312 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.6">Sec. 10.4.6</a></td> 313 * <td> </td> 314 * </tr> 315 * <tr> 316 * <td>{@link #NOT_ACCEPTABLE_406}</td> 317 * <td>406</td> 318 * <td>Not Acceptable</td> 319 * <td> </td> 320 * <td> 321 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.7">Sec. 10.4.7</a></td> 322 * <td> </td> 323 * </tr> 324 * <tr> 325 * <td>{@link #PROXY_AUTHENTICATION_REQUIRED_407}</td> 326 * <td>407</td> 327 * <td>Proxy Authentication Required</td> 328 * <td> </td> 329 * <td> 330 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.8">Sec. 10.4.8</a></td> 331 * <td> </td> 332 * </tr> 333 * <tr> 334 * <td>{@link #REQUEST_TIMEOUT_408}</td> 335 * <td>408</td> 336 * <td>Request Timeout</td> 337 * <td> </td> 338 * <td> 339 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.9">Sec. 10.4.9</a></td> 340 * <td> </td> 341 * </tr> 342 * <tr> 343 * <td>{@link #CONFLICT_409}</td> 344 * <td>409</td> 345 * <td>Conflict</td> 346 * <td> </td> 347 * <td> 348 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.10">Sec. 10.4.10</a> 349 * </td> 350 * <td> </td> 351 * </tr> 352 * <tr> 353 * <td>{@link #GONE_410}</td> 354 * <td>410</td> 355 * <td>Gone</td> 356 * <td> </td> 357 * <td> 358 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.11">Sec. 10.4.11</a> 359 * </td> 360 * <td> </td> 361 * </tr> 362 * <tr> 363 * <td>{@link #LENGTH_REQUIRED_411}</td> 364 * <td>411</td> 365 * <td>Length Required</td> 366 * <td> </td> 367 * <td> 368 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.12">Sec. 10.4.12</a> 369 * </td> 370 * <td> </td> 371 * </tr> 372 * <tr> 373 * <td>{@link #PRECONDITION_FAILED_412}</td> 374 * <td>412</td> 375 * <td>Precondition Failed</td> 376 * <td> </td> 377 * <td> 378 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.13">Sec. 10.4.13</a> 379 * </td> 380 * <td> </td> 381 * </tr> 382 * <tr> 383 * <td>{@link #REQUEST_ENTITY_TOO_LARGE_413}</td> 384 * <td>413</td> 385 * <td>Request Entity Too Large</td> 386 * <td> </td> 387 * <td> 388 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.14">Sec. 10.4.14</a> 389 * </td> 390 * <td> </td> 391 * </tr> 392 * <tr> 393 * <td>{@link #REQUEST_URI_TOO_LONG_414}</td> 394 * <td>414</td> 395 * <td>Request-URI Too Long</td> 396 * <td> </td> 397 * <td> 398 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.15">Sec. 10.4.15</a> 399 * </td> 400 * <td> </td> 401 * </tr> 402 * <tr> 403 * <td>{@link #UNSUPPORTED_MEDIA_TYPE_415}</td> 404 * <td>415</td> 405 * <td>Unsupported Media Type</td> 406 * <td> </td> 407 * <td> 408 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.16">Sec. 10.4.16</a> 409 * </td> 410 * <td> </td> 411 * </tr> 412 * <tr> 413 * <td>{@link #REQUESTED_RANGE_NOT_SATISFIABLE_416}</td> 414 * <td>416</td> 415 * <td>Requested Range Not Satisfiable</td> 416 * <td> </td> 417 * <td> 418 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.17">Sec. 10.4.17</a> 419 * </td> 420 * <td> </td> 421 * </tr> 422 * <tr> 423 * <td>{@link #EXPECTATION_FAILED_417}</td> 424 * <td>417</td> 425 * <td>Expectation Failed</td> 426 * <td> </td> 427 * <td> 428 * <a href="http://tools.ietf.org/html/rfc2616#section-10.4.18">Sec. 10.4.18</a> 429 * </td> 430 * <td> </td> 431 * </tr> 432 * <tr> 433 * <td> </td> 434 * <td><strike>418</strike></td> 435 * <td><strike>Reauthentication Required</strike></td> 436 * <td> </td> 437 * <td> 438 * <a href= 439 * "http://tools.ietf.org/html/draft-ietf-http-v11-spec-rev-01#section-10.4.19" 440 * >draft/01</a></td> 441 * <td> </td> 442 * </tr> 443 * <tr> 444 * <td> </td> 445 * <td><strike>418</strike></td> 446 * <td><strike>Unprocessable Entity</strike></td> 447 * <td> </td> 448 * <td> </td> 449 * <td> 450 * <a href= 451 * "http://tools.ietf.org/html/draft-ietf-webdav-protocol-05#section-10.3" 452 * >draft/05</a></td> 453 * </tr> 454 * <tr> 455 * <td> </td> 456 * <td><strike>419</strike></td> 457 * <td><strike>Proxy Reauthentication Required</stike></td> 458 * <td> </td> 459 * <td> 460 * <a href= 461 * "http://tools.ietf.org/html/draft-ietf-http-v11-spec-rev-01#section-10.4.20" 462 * >draft/01</a></td> 463 * <td> </td> 464 * </tr> 465 * <tr> 466 * <td> </td> 467 * <td><strike>419</strike></td> 468 * <td><strike>Insufficient Space on Resource</stike></td> 469 * <td> </td> 470 * <td> </td> 471 * <td> 472 * <a href= 473 * "http://tools.ietf.org/html/draft-ietf-webdav-protocol-05#section-10.4" 474 * >draft/05</a></td> 475 * </tr> 476 * <tr> 477 * <td> </td> 478 * <td><strike>420</strike></td> 479 * <td><strike>Method Failure</strike></td> 480 * <td> </td> 481 * <td> </td> 482 * <td> 483 * <a href= 484 * "http://tools.ietf.org/html/draft-ietf-webdav-protocol-05#section-10.5" 485 * >draft/05</a></td> 486 * </tr> 487 * <tr> 488 * <td> </td> 489 * <td>421</td> 490 * <td><em>(Unused)</em></td> 491 * <td> </td> 492 * <td> </td> 493 * <td> </td> 494 * </tr> 495 * <tr> 496 * <td>{@link #UNPROCESSABLE_ENTITY_422}</td> 497 * <td>422</td> 498 * <td>Unprocessable Entity</td> 499 * <td> </td> 500 * <td> </td> 501 * <td> 502 * <a href="http://tools.ietf.org/html/rfc2518#section-10.3">Sec. 10.3</a></td> 503 * </tr> 504 * <tr> 505 * <td>{@link #LOCKED_423}</td> 506 * <td>423</td> 507 * <td>Locked</td> 508 * <td> </td> 509 * <td> </td> 510 * <td> 511 * <a href="http://tools.ietf.org/html/rfc2518#section-10.4">Sec. 10.4</a></td> 512 * </tr> 513 * <tr> 514 * <td>{@link #FAILED_DEPENDENCY_424}</td> 515 * <td>424</td> 516 * <td>Failed Dependency</td> 517 * <td> </td> 518 * <td> </td> 519 * <td> 520 * <a href="http://tools.ietf.org/html/rfc2518#section-10.5">Sec. 10.5</a></td> 521 * </tr> 522 * 523 * <tr> 524 * <td><strong><code>Server Error - 5xx</code></strong></td> 525 * <td colspan="5">{@link #isServerError(int)}</td> 526 * </tr> 527 * 528 * <tr> 529 * <td>{@link #INTERNAL_SERVER_ERROR_500}</td> 530 * <td>500</td> 531 * <td>Internal Server Error</td> 532 * <td> 533 * <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td> 534 * <td> 535 * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.1">Sec. 10.5.1</a></td> 536 * <td> </td> 537 * </tr> 538 * <tr> 539 * <td>{@link #NOT_IMPLEMENTED_501}</td> 540 * <td>501</td> 541 * <td>Not Implemented</td> 542 * <td> 543 * <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td> 544 * <td> 545 * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.2">Sec. 10.5.2</a></td> 546 * <td> </td> 547 * </tr> 548 * <tr> 549 * <td>{@link #BAD_GATEWAY_502}</td> 550 * <td>502</td> 551 * <td>Bad Gateway</td> 552 * <td> 553 * <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td> 554 * <td> 555 * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.3">Sec. 10.5.3</a></td> 556 * <td> </td> 557 * </tr> 558 * <tr> 559 * <td>{@link #SERVICE_UNAVAILABLE_503}</td> 560 * <td>503</td> 561 * <td>Service Unavailable</td> 562 * <td> 563 * <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td> 564 * <td> 565 * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.4">Sec. 10.5.4</a></td> 566 * <td> </td> 567 * </tr> 568 * <tr> 569 * <td>{@link #GATEWAY_TIMEOUT_504}</td> 570 * <td>504</td> 571 * <td>Gateway Timeout</td> 572 * <td> </td> 573 * <td> 574 * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.5">Sec. 10.5.5</a></td> 575 * <td> </td> 576 * </tr> 577 * <tr> 578 * <td>{@link #HTTP_VERSION_NOT_SUPPORTED_505}</td> 579 * <td>505</td> 580 * <td>HTTP Version Not Supported</td> 581 * <td> </td> 582 * <td> 583 * <a href="http://tools.ietf.org/html/rfc2616#section-10.5.6">Sec. 10.5.6</a></td> 584 * <td> </td> 585 * </tr> 586 * <tr> 587 * <td> </td> 588 * <td>506</td> 589 * <td><em>(Unused)</em></td> 590 * <td> </td> 591 * <td> </td> 592 * <td> </td> 593 * </tr> 594 * <tr> 595 * <td>{@link #INSUFFICIENT_STORAGE_507}</td> 596 * <td>507</td> 597 * <td>Insufficient Storage</td> 598 * <td> </td> 599 * <td> </td> 600 * <td> 601 * <a href="http://tools.ietf.org/html/rfc2518#section-10.6">Sec. 10.6</a></td> 602 * </tr> 603 * 604 * </table> 605 * 606 * @version $Id$ 607 */ 608 public class HttpStatus 609 { 610 public final static int CONTINUE_100 = 100; 611 public final static int SWITCHING_PROTOCOLS_101 = 101; 612 public final static int PROCESSING_102 = 102; 613 614 public final static int OK_200 = 200; 615 public final static int CREATED_201 = 201; 616 public final static int ACCEPTED_202 = 202; 617 public final static int NON_AUTHORITATIVE_INFORMATION_203 = 203; 618 public final static int NO_CONTENT_204 = 204; 619 public final static int RESET_CONTENT_205 = 205; 620 public final static int PARTIAL_CONTENT_206 = 206; 621 public final static int MULTI_STATUS_207 = 207; 622 623 public final static int MULTIPLE_CHOICES_300 = 300; 624 public final static int MOVED_PERMANENTLY_301 = 301; 625 public final static int MOVED_TEMPORARILY_302 = 302; 626 public final static int FOUND_302 = 302; 627 public final static int SEE_OTHER_303 = 303; 628 public final static int NOT_MODIFIED_304 = 304; 629 public final static int USE_PROXY_305 = 305; 630 public final static int TEMPORARY_REDIRECT_307 = 307; 631 632 public final static int BAD_REQUEST_400 = 400; 633 public final static int UNAUTHORIZED_401 = 401; 634 public final static int PAYMENT_REQUIRED_402 = 402; 635 public final static int FORBIDDEN_403 = 403; 636 public final static int NOT_FOUND_404 = 404; 637 public final static int METHOD_NOT_ALLOWED_405 = 405; 638 public final static int NOT_ACCEPTABLE_406 = 406; 639 public final static int PROXY_AUTHENTICATION_REQUIRED_407 = 407; 640 public final static int REQUEST_TIMEOUT_408 = 408; 641 public final static int CONFLICT_409 = 409; 642 public final static int GONE_410 = 410; 643 public final static int LENGTH_REQUIRED_411 = 411; 644 public final static int PRECONDITION_FAILED_412 = 412; 645 public final static int REQUEST_ENTITY_TOO_LARGE_413 = 413; 646 public final static int REQUEST_URI_TOO_LONG_414 = 414; 647 public final static int UNSUPPORTED_MEDIA_TYPE_415 = 415; 648 public final static int REQUESTED_RANGE_NOT_SATISFIABLE_416 = 416; 649 public final static int EXPECTATION_FAILED_417 = 417; 650 public final static int UNPROCESSABLE_ENTITY_422 = 422; 651 public final static int LOCKED_423 = 423; 652 public final static int FAILED_DEPENDENCY_424 = 424; 653 654 public final static int INTERNAL_SERVER_ERROR_500 = 500; 655 public final static int NOT_IMPLEMENTED_501 = 501; 656 public final static int BAD_GATEWAY_502 = 502; 657 public final static int SERVICE_UNAVAILABLE_503 = 503; 658 public final static int GATEWAY_TIMEOUT_504 = 504; 659 public final static int HTTP_VERSION_NOT_SUPPORTED_505 = 505; 660 public final static int INSUFFICIENT_STORAGE_507 = 507; 661 662 public static final int MAX_CODE = 507; 663 664 665 private static final Code[] codeMap = new Code[MAX_CODE+1]; 666 667 static 668 { 669 for (Code code : Code.values()) 670 { 671 codeMap[code._code] = code; 672 } 673 } 674 675 676 public enum Code 677 { 678 /* 679 * -------------------------------------------------------------------- 680 * Informational messages in 1xx series. As defined by ... RFC 1945 - 681 * HTTP/1.0 RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV 682 */ 683 684 /** <code>100 Continue</code> */ 685 CONTINUE(CONTINUE_100, "Continue"), 686 /** <code>101 Switching Protocols</code> */ 687 SWITCHING_PROTOCOLS(SWITCHING_PROTOCOLS_101, "Switching Protocols"), 688 /** <code>102 Processing</code> */ 689 PROCESSING(PROCESSING_102, "Processing"), 690 691 /* 692 * -------------------------------------------------------------------- 693 * Success messages in 2xx series. As defined by ... RFC 1945 - HTTP/1.0 694 * RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV 695 */ 696 697 /** <code>200 OK</code> */ 698 OK(OK_200, "OK"), 699 /** <code>201 Created</code> */ 700 CREATED(CREATED_201, "Created"), 701 /** <code>202 Accepted</code> */ 702 ACCEPTED(ACCEPTED_202, "Accepted"), 703 /** <code>203 Non Authoritative Information</code> */ 704 NON_AUTHORITATIVE_INFORMATION(NON_AUTHORITATIVE_INFORMATION_203, "Non Authoritative Information"), 705 /** <code>204 No Content</code> */ 706 NO_CONTENT(NO_CONTENT_204, "No Content"), 707 /** <code>205 Reset Content</code> */ 708 RESET_CONTENT(RESET_CONTENT_205, "Reset Content"), 709 /** <code>206 Partial Content</code> */ 710 PARTIAL_CONTENT(PARTIAL_CONTENT_206, "Partial Content"), 711 /** <code>207 Multi-Status</code> */ 712 MULTI_STATUS(MULTI_STATUS_207, "Multi-Status"), 713 714 /* 715 * -------------------------------------------------------------------- 716 * Redirection messages in 3xx series. As defined by ... RFC 1945 - 717 * HTTP/1.0 RFC 2616 - HTTP/1.1 718 */ 719 720 /** <code>300 Mutliple Choices</code> */ 721 MULTIPLE_CHOICES(MULTIPLE_CHOICES_300, "Multiple Choices"), 722 /** <code>301 Moved Permanently</code> */ 723 MOVED_PERMANENTLY(MOVED_PERMANENTLY_301, "Moved Permanently"), 724 /** <code>302 Moved Temporarily</code> */ 725 MOVED_TEMPORARILY(MOVED_TEMPORARILY_302, "Moved Temporarily"), 726 /** <code>302 Found</code> */ 727 FOUND(FOUND_302, "Found"), 728 /** <code>303 See Other</code> */ 729 SEE_OTHER(SEE_OTHER_303, "See Other"), 730 /** <code>304 Not Modified</code> */ 731 NOT_MODIFIED(NOT_MODIFIED_304, "Not Modified"), 732 /** <code>305 Use Proxy</code> */ 733 USE_PROXY(USE_PROXY_305, "Use Proxy"), 734 /** <code>307 Temporary Redirect</code> */ 735 TEMPORARY_REDIRECT(TEMPORARY_REDIRECT_307, "Temporary Redirect"), 736 737 /* 738 * -------------------------------------------------------------------- 739 * Client Error messages in 4xx series. As defined by ... RFC 1945 - 740 * HTTP/1.0 RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV 741 */ 742 743 /** <code>400 Bad Request</code> */ 744 BAD_REQUEST(BAD_REQUEST_400, "Bad Request"), 745 /** <code>401 Unauthorized</code> */ 746 UNAUTHORIZED(UNAUTHORIZED_401, "Unauthorized"), 747 /** <code>402 Payment Required</code> */ 748 PAYMENT_REQUIRED(PAYMENT_REQUIRED_402, "Payment Required"), 749 /** <code>403 Forbidden</code> */ 750 FORBIDDEN(FORBIDDEN_403, "Forbidden"), 751 /** <code>404 Not Found</code> */ 752 NOT_FOUND(NOT_FOUND_404, "Not Found"), 753 /** <code>405 Method Not Allowed</code> */ 754 METHOD_NOT_ALLOWED(METHOD_NOT_ALLOWED_405, "Method Not Allowed"), 755 /** <code>406 Not Acceptable</code> */ 756 NOT_ACCEPTABLE(NOT_ACCEPTABLE_406, "Not Acceptable"), 757 /** <code>407 Proxy Authentication Required</code> */ 758 PROXY_AUTHENTICATION_REQUIRED(PROXY_AUTHENTICATION_REQUIRED_407, "Proxy Authentication Required"), 759 /** <code>408 Request Timeout</code> */ 760 REQUEST_TIMEOUT(REQUEST_TIMEOUT_408, "Request Timeout"), 761 /** <code>409 Conflict</code> */ 762 CONFLICT(CONFLICT_409, "Conflict"), 763 /** <code>410 Gone</code> */ 764 GONE(GONE_410, "Gone"), 765 /** <code>411 Length Required</code> */ 766 LENGTH_REQUIRED(LENGTH_REQUIRED_411, "Length Required"), 767 /** <code>412 Precondition Failed</code> */ 768 PRECONDITION_FAILED(PRECONDITION_FAILED_412, "Precondition Failed"), 769 /** <code>413 Request Entity Too Large</code> */ 770 REQUEST_ENTITY_TOO_LARGE(REQUEST_ENTITY_TOO_LARGE_413, "Request Entity Too Large"), 771 /** <code>414 Request-URI Too Long</code> */ 772 REQUEST_URI_TOO_LONG(REQUEST_URI_TOO_LONG_414, "Request-URI Too Long"), 773 /** <code>415 Unsupported Media Type</code> */ 774 UNSUPPORTED_MEDIA_TYPE(UNSUPPORTED_MEDIA_TYPE_415, "Unsupported Media Type"), 775 /** <code>416 Requested Range Not Satisfiable</code> */ 776 REQUESTED_RANGE_NOT_SATISFIABLE(REQUESTED_RANGE_NOT_SATISFIABLE_416, "Requested Range Not Satisfiable"), 777 /** <code>417 Expectation Failed</code> */ 778 EXPECTATION_FAILED(EXPECTATION_FAILED_417, "Expectation Failed"), 779 /** <code>422 Unprocessable Entity</code> */ 780 UNPROCESSABLE_ENTITY(UNPROCESSABLE_ENTITY_422, "Unprocessable Entity"), 781 /** <code>423 Locked</code> */ 782 LOCKED(LOCKED_423, "Locked"), 783 /** <code>424 Failed Dependency</code> */ 784 FAILED_DEPENDENCY(FAILED_DEPENDENCY_424, "Failed Dependency"), 785 786 /* 787 * -------------------------------------------------------------------- 788 * Server Error messages in 5xx series. As defined by ... RFC 1945 - 789 * HTTP/1.0 RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV 790 */ 791 792 /** <code>500 Server Error</code> */ 793 INTERNAL_SERVER_ERROR(INTERNAL_SERVER_ERROR_500, "Server Error"), 794 /** <code>501 Not Implemented</code> */ 795 NOT_IMPLEMENTED(NOT_IMPLEMENTED_501, "Not Implemented"), 796 /** <code>502 Bad Gateway</code> */ 797 BAD_GATEWAY(BAD_GATEWAY_502, "Bad Gateway"), 798 /** <code>503 Service Unavailable</code> */ 799 SERVICE_UNAVAILABLE(SERVICE_UNAVAILABLE_503, "Service Unavailable"), 800 /** <code>504 Gateway Timeout</code> */ 801 GATEWAY_TIMEOUT(GATEWAY_TIMEOUT_504, "Gateway Timeout"), 802 /** <code>505 HTTP Version Not Supported</code> */ 803 HTTP_VERSION_NOT_SUPPORTED(HTTP_VERSION_NOT_SUPPORTED_505, "HTTP Version Not Supported"), 804 /** <code>507 Insufficient Storage</code> */ 805 INSUFFICIENT_STORAGE(INSUFFICIENT_STORAGE_507, "Insufficient Storage"); 806 807 private final int _code; 808 private final String _message; 809 810 private Code(int code, String message) 811 { 812 this._code = code; 813 _message=message; 814 } 815 816 public int getCode() 817 { 818 return _code; 819 } 820 821 public String getMessage() 822 { 823 return _message; 824 } 825 826 827 public boolean equals(int code) 828 { 829 return (this._code == code); 830 } 831 832 @Override 833 public String toString() 834 { 835 return String.format("[%03d %s]",this._code,this.getMessage()); 836 } 837 838 /** 839 * Simple test against an code to determine if it falls into the 840 * <code>Informational</code> message category as defined in the <a 841 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, 842 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - 843 * HTTP/1.1</a>. 844 * 845 * @return true if within range of codes that belongs to 846 * <code>Informational</code> messages. 847 */ 848 public boolean isInformational() 849 { 850 return HttpStatus.isInformational(this._code); 851 } 852 853 /** 854 * Simple test against an code to determine if it falls into the 855 * <code>Success</code> message category as defined in the <a 856 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, 857 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - 858 * HTTP/1.1</a>. 859 * 860 * @return true if within range of codes that belongs to 861 * <code>Success</code> messages. 862 */ 863 public boolean isSuccess() 864 { 865 return HttpStatus.isSuccess(this._code); 866 } 867 868 /** 869 * Simple test against an code to determine if it falls into the 870 * <code>Redirection</code> message category as defined in the <a 871 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, 872 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - 873 * HTTP/1.1</a>. 874 * 875 * @return true if within range of codes that belongs to 876 * <code>Redirection</code> messages. 877 */ 878 public boolean isRedirection() 879 { 880 return HttpStatus.isRedirection(this._code); 881 } 882 883 /** 884 * Simple test against an code to determine if it falls into the 885 * <code>Client Error</code> message category as defined in the <a 886 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, 887 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - 888 * HTTP/1.1</a>. 889 * 890 * @return true if within range of codes that belongs to 891 * <code>Client Error</code> messages. 892 */ 893 public boolean isClientError() 894 { 895 return HttpStatus.isClientError(this._code); 896 } 897 898 /** 899 * Simple test against an code to determine if it falls into the 900 * <code>Server Error</code> message category as defined in the <a 901 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, 902 * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - 903 * HTTP/1.1</a>. 904 * 905 * @return true if within range of codes that belongs to 906 * <code>Server Error</code> messages. 907 */ 908 public boolean isServerError() 909 { 910 return HttpStatus.isServerError(this._code); 911 } 912 } 913 914 915 /** 916 * Get the HttpStatusCode for a specific code 917 * 918 * @param code 919 * the code to lookup. 920 * @return the {@link HttpStatus} if found, or null if not found. 921 */ 922 public static Code getCode(int code) 923 { 924 if (code <= MAX_CODE) 925 { 926 return codeMap[code]; 927 } 928 return null; 929 } 930 931 /** 932 * Get the status message for a specific code. 933 * 934 * @param code 935 * the code to look up 936 * @return the specific message, or the code number itself if code 937 * does not match known list. 938 */ 939 public static String getMessage(int code) 940 { 941 Code codeEnum = getCode(code); 942 if (codeEnum != null) 943 { 944 return codeEnum.getMessage(); 945 } 946 else 947 { 948 return Integer.toString(code); 949 } 950 } 951 952 /** 953 * Simple test against an code to determine if it falls into the 954 * <code>Informational</code> message category as defined in the <a 955 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a 956 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>. 957 * 958 * @param code 959 * the code to test. 960 * @return true if within range of codes that belongs to 961 * <code>Informational</code> messages. 962 */ 963 public static boolean isInformational(int code) 964 { 965 return ((100 <= code) && (code <= 199)); 966 } 967 968 /** 969 * Simple test against an code to determine if it falls into the 970 * <code>Success</code> message category as defined in the <a 971 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a 972 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>. 973 * 974 * @param code 975 * the code to test. 976 * @return true if within range of codes that belongs to 977 * <code>Success</code> messages. 978 */ 979 public static boolean isSuccess(int code) 980 { 981 return ((200 <= code) && (code <= 299)); 982 } 983 984 /** 985 * Simple test against an code to determine if it falls into the 986 * <code>Redirection</code> message category as defined in the <a 987 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a 988 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>. 989 * 990 * @param code 991 * the code to test. 992 * @return true if within range of codes that belongs to 993 * <code>Redirection</code> messages. 994 */ 995 public static boolean isRedirection(int code) 996 { 997 return ((300 <= code) && (code <= 399)); 998 } 999 1000 /** 1001 * Simple test against an code to determine if it falls into the 1002 * <code>Client Error</code> message category as defined in the <a 1003 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a 1004 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>. 1005 * 1006 * @param code 1007 * the code to test. 1008 * @return true if within range of codes that belongs to 1009 * <code>Client Error</code> messages. 1010 */ 1011 public static boolean isClientError(int code) 1012 { 1013 return ((400 <= code) && (code <= 499)); 1014 } 1015 1016 /** 1017 * Simple test against an code to determine if it falls into the 1018 * <code>Server Error</code> message category as defined in the <a 1019 * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a 1020 * href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>. 1021 * 1022 * @param code 1023 * the code to test. 1024 * @return true if within range of codes that belongs to 1025 * <code>Server Error</code> messages. 1026 */ 1027 public static boolean isServerError(int code) 1028 { 1029 return ((500 <= code) && (code <= 599)); 1030 } 1031 }