tinywebd

view 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 source
1 #ifndef HTTP_H_
2 #define HTTP_H_
4 enum http_method {
5 HTTP_UNKNOWN,
6 HTTP_OPTIONS,
7 HTTP_GET,
8 HTTP_HEAD,
9 HTTP_POST,
10 HTTP_PUT,
11 HTTP_DELETE,
12 HTTP_TRACE,
13 HTTP_CONNECT,
15 NUM_HTTP_METHODS
16 };
18 const char *http_method_str[] = {
19 "<unknown>",
20 "OPTIONS",
21 "GET",
22 "HEAD",
23 "POST",
24 "PUT",
25 "DELETE",
26 "TRACE",
27 "CONNECT",
28 0
29 };
32 struct http_req_header {
33 enum http_method method;
34 char *uri;
35 int ver_major, ver_minor; /* http version */
36 /* XXX cont. */
37 };
40 /* HTTP 1xx message strings */
41 const char *http_msg1xx[] = {
42 "Continue", /* 100 */
43 "Switching Protocols" /* 101 */
44 };
46 /* HTTP 2xx message strings */
47 const char *http_msg2xx[] = {
48 "OK", /* 200 */
49 "Created", /* 201 */
50 "Accepted", /* 202 */
51 "Non-Authoritative Information", /* 203 */
52 "No Content", /* 204 */
53 "Reset Content", /* 205 */
54 "Partial Content" /* 206 */
55 };
57 /* HTTP 3xx message strings */
58 const char *http_msg3xx[] = {
59 "Multiple Choices", /* 300 */
60 "Moved Permanently", /* 301 */
61 "Found", /* 302 */
62 "See Other", /* 303 */
63 "Not Modified", /* 304 */
64 "Use Proxy", /* 305 */
65 "<unknown>", /* 306 is undefined? */
66 "Temporary Redirect" /* 307 */
67 };
69 /* HTTP 4xx error strings */
70 const char *http_msg4xx[] = {
71 "Bad Request", /* 400 */
72 "Unauthorized", /* 401 */
73 "What the Fuck?", /* 402 */
74 "Forbidden", /* 403 */
75 "Not Found", /* 404 */
76 "Method Not Allowed", /* 405 */
77 "Not Acceptable", /* 406 */
78 "Proxy Authentication Required", /* 407 */
79 "Request Time-out", /* 408 */
80 "Conflict", /* 409 */
81 "Gone", /* 410 */
82 "Length Required", /* 411 */
83 "Precondition Failed", /* 412 */
84 "Request Entity Too Large", /* 413 */
85 "Request-URI Too Large", /* 414 */
86 "Unsupported Media Type", /* 415 */
87 "Request range not satisfiable", /* 416 */
88 "Expectation Failed" /* 417 */
89 };
91 /* HTTP 5xx error strings */
92 const char *http_msg5xx[] = {
93 "Internal Server Error", /* 500 */
94 "Not Implemented", /* 501 */
95 "Bad Gateway", /* 502 */
96 "Service Unavailable", /* 503 */
97 "Gateway Time-out", /* 504 */
98 "HTTP Version not supported" /* 505 */
99 };
101 const char *http_strmsg(int code);
103 #endif /* HTTP_H_ */