1 2 24 25 26 27 28 29 package com.lutris.http; 30 31 public class HttpStatus { 32 33 public final static int doContinue = 100; 35 public final static int switchingProtocols = 101; 36 37 public final static int ok = 200; 39 public final static int created = 201; 40 public final static int accepted = 202; 41 public final static int nonAuthoritativeInformation = 203; 42 public final static int noContent = 204; 43 public final static int resetContent = 205; 44 public final static int partialContent = 206; 45 46 public final static int multipleChoices = 300; 48 public final static int movedPermanently = 301; 49 public final static int movedTemporarily = 302; 50 public final static int seeOther = 303; 51 public final static int notModified = 304; 52 public final static int useProxy = 305; 53 54 public final static int badRequest = 400; 56 public final static int unauthorized = 401; 57 public final static int paymentRequired = 402; 58 public final static int forbidden = 403; 59 public final static int notFound = 404; 60 public final static int methodNotAllowed = 405; 61 public final static int notAcceptable = 406; 62 public final static int proxyAuthenticationRequired = 407; 63 public final static int requestTimeout = 408; 64 public final static int conflict = 409; 65 public final static int gone = 410; 66 public final static int lenghtRequired = 411; 67 public final static int preconditionFailed = 412; 68 public final static int requestEntityTooLarge = 413; 69 public final static int requestUriTooLarge = 414; 70 public final static int unsupportedMediaType = 415; 71 72 public final static int internalServerError = 500; 74 public final static int notImplemented = 501; 75 public final static int badGateway = 502; 76 public final static int serviceUnavailable = 503; 77 public final static int gatewayTimeout = 504; 78 public final static int httpVersionNotSupported = 505; 79 80 86 private static final String [][] statusMsgs = { 87 { 88 "Continue", 89 "Switching Protocols", 90 "Informational", 91 }, { 92 "OK", 93 "Created", 94 "Accepted", 95 "Non-Authoritative Information", 96 "No Content", 97 "Reset Content", 98 "Partial Content", 99 "Success", 100 }, { 101 "Multiple Choices", 102 "Moved Permanently", 103 "Moved Temporarily", 104 "See Other", 105 "Not Modified", 106 "Use Proxy", 107 "Redirection", 108 }, { 109 "Bad Request", 110 "Unauthorized", 111 "Payment Required", 112 "Forbidden", 113 "Not Found", 114 "Method Not Allowed", 115 "Not Acceptable", 116 "Proxy Authentication Required", 117 "Request Time-out", 118 "Conflict", 119 "Gone", 120 "Length Required", 121 "Precondition Failed", 122 "Request Entity Too Large", 123 "Request-URI Too Large", 124 "Unsupported Media Type", 125 "Client Error", 126 }, { 127 "Internal Server Error", 128 "Not Implemented", 129 "Bad Gateway", 130 "Service Unavailable", 131 "Gateway Time-out", 132 "HTTP Version not supported", 133 "Server Error", 134 } 135 }; 136 137 140 public static String getStatusMsg(int statusCode) { 141 int codeSet = (statusCode / 100); 142 int setIdx = statusCode - (codeSet * 100); 143 if ((codeSet <= 0) || (codeSet > statusMsgs.length)) { 144 return "Invalid status code"; 145 } 146 if (setIdx >= statusMsgs[codeSet-1].length) { 147 setIdx = statusMsgs[codeSet-1].length - 1; 148 } 149 return statusMsgs[codeSet-1][setIdx]; 150 } 151 } 152 | Popular Tags |