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