tinywebd
diff src/http.h @ 1:f425a9805d17
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 14 Apr 2015 08:32:51 +0300 |
parents | |
children | 7bb4c2a0a360 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/http.h Tue Apr 14 08:32:51 2015 +0300 1.3 @@ -0,0 +1,103 @@ 1.4 +#ifndef HTTP_H_ 1.5 +#define HTTP_H_ 1.6 + 1.7 +enum http_method { 1.8 + HTTP_UNKNOWN, 1.9 + HTTP_OPTIONS, 1.10 + HTTP_GET, 1.11 + HTTP_HEAD, 1.12 + HTTP_POST, 1.13 + HTTP_PUT, 1.14 + HTTP_DELETE, 1.15 + HTTP_TRACE, 1.16 + HTTP_CONNECT, 1.17 + 1.18 + NUM_HTTP_METHODS 1.19 +}; 1.20 + 1.21 +const char *http_method_str[] = { 1.22 + "<unknown>", 1.23 + "OPTIONS", 1.24 + "GET", 1.25 + "HEAD", 1.26 + "POST", 1.27 + "PUT", 1.28 + "DELETE", 1.29 + "TRACE", 1.30 + "CONNECT", 1.31 + 0 1.32 +}; 1.33 + 1.34 + 1.35 +struct http_req_header { 1.36 + enum http_method method; 1.37 + char *uri; 1.38 + int ver_major, ver_minor; /* http version */ 1.39 + /* XXX cont. */ 1.40 +}; 1.41 + 1.42 + 1.43 +/* HTTP 1xx message strings */ 1.44 +const char *http_msg1xx[] = { 1.45 + "Continue", /* 100 */ 1.46 + "Switching Protocols" /* 101 */ 1.47 +}; 1.48 + 1.49 +/* HTTP 2xx message strings */ 1.50 +const char *http_msg2xx[] = { 1.51 + "OK", /* 200 */ 1.52 + "Created", /* 201 */ 1.53 + "Accepted", /* 202 */ 1.54 + "Non-Authoritative Information", /* 203 */ 1.55 + "No Content", /* 204 */ 1.56 + "Reset Content", /* 205 */ 1.57 + "Partial Content" /* 206 */ 1.58 +}; 1.59 + 1.60 +/* HTTP 3xx message strings */ 1.61 +const char *http_msg3xx[] = { 1.62 + "Multiple Choices", /* 300 */ 1.63 + "Moved Permanently", /* 301 */ 1.64 + "Found", /* 302 */ 1.65 + "See Other", /* 303 */ 1.66 + "Not Modified", /* 304 */ 1.67 + "Use Proxy", /* 305 */ 1.68 + "<unknown>", /* 306 is undefined? */ 1.69 + "Temporary Redirect" /* 307 */ 1.70 +}; 1.71 + 1.72 +/* HTTP 4xx error strings */ 1.73 +const char *http_msg4xx[] = { 1.74 + "Bad Request", /* 400 */ 1.75 + "Unauthorized", /* 401 */ 1.76 + "What the Fuck?", /* 402 */ 1.77 + "Forbidden", /* 403 */ 1.78 + "Not Found", /* 404 */ 1.79 + "Method Not Allowed", /* 405 */ 1.80 + "Not Acceptable", /* 406 */ 1.81 + "Proxy Authentication Required", /* 407 */ 1.82 + "Request Time-out", /* 408 */ 1.83 + "Conflict", /* 409 */ 1.84 + "Gone", /* 410 */ 1.85 + "Length Required", /* 411 */ 1.86 + "Precondition Failed", /* 412 */ 1.87 + "Request Entity Too Large", /* 413 */ 1.88 + "Request-URI Too Large", /* 414 */ 1.89 + "Unsupported Media Type", /* 415 */ 1.90 + "Request range not satisfiable", /* 416 */ 1.91 + "Expectation Failed" /* 417 */ 1.92 +}; 1.93 + 1.94 +/* HTTP 5xx error strings */ 1.95 +const char *http_msg5xx[] = { 1.96 + "Internal Server Error", /* 500 */ 1.97 + "Not Implemented", /* 501 */ 1.98 + "Bad Gateway", /* 502 */ 1.99 + "Service Unavailable", /* 503 */ 1.100 + "Gateway Time-out", /* 504 */ 1.101 + "HTTP Version not supported" /* 505 */ 1.102 +}; 1.103 + 1.104 +const char *http_strmsg(int code); 1.105 + 1.106 +#endif /* HTTP_H_ */