28 #ifndef HTTP_CONSTANTS_HPP
29 #define HTTP_CONSTANTS_HPP
74 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
75 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
76 0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,
77 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,
78 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
79 1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,
80 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
81 1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,
82 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
83 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
84 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
85 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
86 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
87 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
88 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
89 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
94 return (header_token[c] == 1);
99 return !header_token[c];
107 return (c == 9 || c == 32);
112 return (c != 9 && c != 32);
116 namespace status_code {
121 switching_protocols = 101,
126 non_authoritative_information = 203,
129 partial_content = 206,
131 multiple_choices = 300,
132 moved_permanently = 301,
137 temporary_redirect = 307,
141 payment_required = 402,
144 method_not_allowed = 405,
145 not_acceptable = 406,
146 proxy_authentication_required = 407,
147 request_timeout = 408,
150 length_required = 411,
151 precondition_failed = 412,
152 request_entity_too_large = 413,
153 request_uri_too_long = 414,
154 unsupported_media_type = 415,
155 request_range_not_satisfiable = 416,
156 expectation_failed = 417,
158 upgrade_required = 426,
159 precondition_required = 428,
160 too_many_requests = 429,
161 request_header_fields_too_large = 431,
163 internal_server_error = 500,
164 not_implemented = 501,
166 service_unavailable = 503,
167 gateway_timeout = 504,
168 http_version_not_supported = 505,
170 network_authentication_required = 511
174 inline std::string get_string(value c) {
177 return "Uninitialized";
180 case switching_protocols:
181 return "Switching Protocols";
188 case non_authoritative_information:
189 return "Non Authoritative Information";
193 return "Reset Content";
194 case partial_content:
195 return "Partial Content";
196 case multiple_choices:
197 return "Multiple Choices";
198 case moved_permanently:
199 return "Moved Permanently";
205 return "Not Modified";
208 case temporary_redirect:
209 return "Temporary Redirect";
211 return "Bad Request";
213 return "Unauthorized";
214 case payment_required:
215 return "Payment Required";
220 case method_not_allowed:
221 return "Method Not Allowed";
223 return "Not Acceptable";
224 case proxy_authentication_required:
225 return "Proxy Authentication Required";
226 case request_timeout:
227 return "Request Timeout";
232 case length_required:
233 return "Length Required";
234 case precondition_failed:
235 return "Precondition Failed";
236 case request_entity_too_large:
237 return "Request Entity Too Large";
238 case request_uri_too_long:
239 return "Request-URI Too Long";
240 case unsupported_media_type:
241 return "Unsupported Media Type";
242 case request_range_not_satisfiable:
243 return "Requested Range Not Satisfiable";
244 case expectation_failed:
245 return "Expectation Failed";
247 return "I'm a teapot";
248 case upgrade_required:
249 return "Upgrade Required";
250 case precondition_required:
251 return "Precondition Required";
252 case too_many_requests:
253 return "Too Many Requests";
254 case request_header_fields_too_large:
255 return "Request Header Fields Too Large";
256 case internal_server_error:
257 return "Internal Server Error";
258 case not_implemented:
259 return "Not Implemented";
261 return "Bad Gateway";
262 case service_unavailable:
263 return "Service Unavailable";
264 case gateway_timeout:
265 return "Gateway Timeout";
266 case http_version_not_supported:
267 return "HTTP Version Not Supported";
269 return "Not Extended";
270 case network_authentication_required:
271 return "Network Authentication Required";
281 status_code::value error_code,
283 const std::string& body =
"")
287 , m_error_code(error_code) {}
291 virtual const char* what()
const throw() {
292 return m_msg.c_str();
296 std::string m_error_msg;
298 status_code::value m_error_code;
303 #endif // HTTP_CONSTANTS_HPP
static std::string const empty_header
Literal value of an empty header.
bool is_not_whitespace_char(unsigned char c)
Is the character non-whitespace.
static char const header_delimiter[]
Literal value of the HTTP header delimiter.
std::vector< std::pair< std::string, attribute_list > > parameter_list
The type of an HTTP parameter list.
bool is_not_token_char(unsigned char c)
Is the character a non-token.
static char const header_separator[]
Literal value of the HTTP header separator.
size_t const istream_buffer
Number of bytes to use for temporary istream read buffers.
static char const header_token[]
invalid HTTP token characters
Namespace for the WebSocket++ project.
size_t const max_header_size
Maximum size in bytes before rejecting an HTTP header as too big.
std::map< std::string, std::string > attribute_list
The type of an HTTP attribute list.
bool is_token_char(unsigned char c)
Is the character a token.
bool is_whitespace_char(unsigned char c)
Is the character whitespace.