从netty源码里拿到的关于http错误码,自己学习下
1 public static HttpResponseStatus valueOf(int code) { 2 switch (code) { 3 case 100: 4 return CONTINUE; 5 case 101: 6 return SWITCHING_PROTOCOLS; 7 case 102: 8 return PROCESSING; 9 case 200: 10 return OK; 11 case 201: 12 return CREATED; 13 case 202: 14 return ACCEPTED; 15 case 203: 16 return NON_AUTHORITATIVE_INFORMATION; 17 case 204: 18 return NO_CONTENT; 19 case 205: 20 return RESET_CONTENT; 21 case 206: 22 return PARTIAL_CONTENT; 23 case 207: 24 return MULTI_STATUS; 25 case 300: 26 return MULTIPLE_CHOICES; 27 case 301: 28 return MOVED_PERMANENTLY; 29 case 302: 30 return FOUND; 31 case 303: 32 return SEE_OTHER; 33 case 304: 34 return NOT_MODIFIED; 35 case 305: 36 return USE_PROXY; 37 case 307: 38 return TEMPORARY_REDIRECT; 39 case 400: 40 return BAD_REQUEST; 41 case 401: 42 return UNAUTHORIZED; 43 case 402: 44 return PAYMENT_REQUIRED; 45 case 403: 46 return FORBIDDEN; 47 case 404: 48 return NOT_FOUND; 49 case 405: 50 return METHOD_NOT_ALLOWED; 51 case 406: 52 return NOT_ACCEPTABLE; 53 case 407: 54 return PROXY_AUTHENTICATION_REQUIRED; 55 case 408: 56 return REQUEST_TIMEOUT; 57 case 409: 58 return CONFLICT; 59 case 410: 60 return GONE; 61 case 411: 62 return LENGTH_REQUIRED; 63 case 412: 64 return PRECONDITION_FAILED; 65 case 413: 66 return REQUEST_ENTITY_TOO_LARGE; 67 case 414: 68 return REQUEST_URI_TOO_LONG; 69 case 415: 70 return UNSUPPORTED_MEDIA_TYPE; 71 case 416: 72 return REQUESTED_RANGE_NOT_SATISFIABLE; 73 case 417: 74 return EXPECTATION_FAILED; 75 case 422: 76 return UNPROCESSABLE_ENTITY; 77 case 423: 78 return LOCKED; 79 case 424: 80 return FAILED_DEPENDENCY; 81 case 425: 82 return UNORDERED_COLLECTION; 83 case 426: 84 return UPGRADE_REQUIRED; 85 case 428: 86 return PRECONDITION_REQUIRED; 87 case 429: 88 return TOO_MANY_REQUESTS; 89 case 431: 90 return REQUEST_HEADER_FIELDS_TOO_LARGE; 91 case 500: 92 return INTERNAL_SERVER_ERROR; 93 case 501: 94 return NOT_IMPLEMENTED; 95 case 502: 96 return BAD_GATEWAY; 97 case 503: 98 return SERVICE_UNAVAILABLE; 99 case 504: 100 return GATEWAY_TIMEOUT; 101 case 505: 102 return HTTP_VERSION_NOT_SUPPORTED; 103 case 506: 104 return VARIANT_ALSO_NEGOTIATES; 105 case 507: 106 return INSUFFICIENT_STORAGE; 107 case 510: 108 return NOT_EXTENDED; 109 case 511: 110 return NETWORK_AUTHENTICATION_REQUIRED; 111 } 112 113 final String reasonPhrase; 114 115 if (code < 100) { 116 reasonPhrase = "Unknown Status"; 117 } else if (code < 200) { 118 reasonPhrase = "Informational"; 119 } else if (code < 300) { 120 reasonPhrase = "Successful"; 121 } else if (code < 400) { 122 reasonPhrase = "Redirection"; 123 } else if (code < 500) { 124 reasonPhrase = "Client Error"; 125 } else if (code < 600) { 126 reasonPhrase = "Server Error"; 127 } else { 128 reasonPhrase = "Unknown Status"; 129 } 130 131 return new HttpResponseStatus(code, reasonPhrase + " (" + code + ')'); 132 }