9 #ifndef __libutilxx__sella__server__Code_H__
10 #define __libutilxx__sella__server__Code_H__
12 #include "../../common.h"
13 #include "../util/String.h"
28 OK = 200, Created = 201, NoContent = 204,
29 BadRequest = 400, Unauthorized = 401, Forbidden = 403, NotFound = 404, MethodNotAllowed = 405, Gone = 410, RequestEntityTooLarge = 413,
30 InternalServerError = 500, NotImplemented = 501, ServiceUnavailable = 503
33 static std::string statusCodeDisplayString(
int code)
throw () {
34 return sella::util::String::sprintf(
"%d ", code).append(statusCodeString(code));
37 static std::string statusCodeString(
int code)
throw () {
40 return std::string(
"Continue");
43 return std::string(
"Switching Protocols");
46 return std::string(
"OK");
49 return std::string(
"Created");
52 return std::string(
"Accepted");
55 return std::string(
"Non-Authoritative Information");
58 return std::string(
"No Content");
61 return std::string(
"Reset Content");
64 return std::string(
"Partial Content");
67 return std::string(
"Multiple Choices");
70 return std::string(
"Moved Permanently");
73 return std::string(
"Found");
76 return std::string(
"See Other");
79 return std::string(
"Not Modified");
82 return std::string(
"Use Proxy");
85 return std::string(
"Temporary Redirect");
88 return std::string(
"Bad Request");
91 return std::string(
"Unauthorized");
94 return std::string(
"Payment Required");
97 return std::string(
"Forbidden");
100 return std::string(
"Not Found");
103 return std::string(
"Method Not Allowed");
106 return std::string(
"Not Acceptable");
109 return std::string(
"Proxy Authentication Required");
112 return std::string(
"Request Time-out");
115 return std::string(
"Conflict");
118 return std::string(
"Gone");
121 return std::string(
"Length Required");
124 return std::string(
"Precondition Failed");
127 return std::string(
"Request Entity Too Large");
130 return std::string(
"Request-URI Too Large");
133 return std::string(
"Unsupported Media Type");
136 return std::string(
"Requested range not satisfiable");
139 return std::string(
"Expectation Failed");
142 return std::string(
"Misdirected Request");
145 return std::string(
"Unprocessable Entity");
148 return std::string(
"Locked");
151 return std::string(
"Failed Dependency");
154 return std::string(
"Upgrade Required");
157 return std::string(
"Precondition Required");
160 return std::string(
"Too Many Requests");
163 return std::string(
"Request Header Fields Too Large");
166 return std::string(
"Unavailable For Legal Reasons");
169 return std::string(
"Invalid Token");
172 return std::string(
"Token Required");
175 return std::string(
"Internal Server Error");
178 return std::string(
"Not Implemented");
181 return std::string(
"Bad Gateway");
184 return std::string(
"Service Unavailable");
187 return std::string(
"Gateway Time-out");
190 return std::string(
"HTTP Version not supported");
193 return std::string(
"Variant Also Negotiates");
196 return std::string(
"Insufficient Storage");
199 return std::string(
"Loop Detected");
202 return std::string(
"Bandwidth Limit Exceeded");
205 return std::string(
"Not Extended");
208 return std::string(
"Network Authentication Required");
211 return std::string(
"Network connect timeout error");
214 if (code >= 500 && code < 600) {
215 return sella::util::String::sprintf(
"Server Error", code);
216 }
else if (code >= 400) {
217 return sella::util::String::sprintf(
"Client Error", code);
218 }
else if (code >= 300) {
219 return sella::util::String::sprintf(
"Redirection", code);
220 }
else if (code >= 200) {
221 return sella::util::String::sprintf(
"Successful", code);
222 }
else if (code >= 100) {
223 return sella::util::String::sprintf(
"Informational", code);
226 return sella::util::String::sprintf(
"Unknown", code);