tinywebd

view src/http.h @ 2:7bb4c2a0a360

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 15 Apr 2015 23:44:22 +0300
parents f425a9805d17
children 852a745503cf
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 char **hdrfields;
37 int num_hdrfields;
38 };
41 int http_parse_header(struct http_req_header *hdr, const char *buf, int bufsz);
43 const char *http_strmsg(int code);
46 /* HTTP 1xx message strings */
47 const char *http_msg1xx[] = {
48 "Continue", /* 100 */
49 "Switching Protocols" /* 101 */
50 };
52 /* HTTP 2xx message strings */
53 const char *http_msg2xx[] = {
54 "OK", /* 200 */
55 "Created", /* 201 */
56 "Accepted", /* 202 */
57 "Non-Authoritative Information", /* 203 */
58 "No Content", /* 204 */
59 "Reset Content", /* 205 */
60 "Partial Content" /* 206 */
61 };
63 /* HTTP 3xx message strings */
64 const char *http_msg3xx[] = {
65 "Multiple Choices", /* 300 */
66 "Moved Permanently", /* 301 */
67 "Found", /* 302 */
68 "See Other", /* 303 */
69 "Not Modified", /* 304 */
70 "Use Proxy", /* 305 */
71 "<unknown>", /* 306 is undefined? */
72 "Temporary Redirect" /* 307 */
73 };
75 /* HTTP 4xx error strings */
76 const char *http_msg4xx[] = {
77 "Bad Request", /* 400 */
78 "Unauthorized", /* 401 */
79 "What the Fuck?", /* 402 */
80 "Forbidden", /* 403 */
81 "Not Found", /* 404 */
82 "Method Not Allowed", /* 405 */
83 "Not Acceptable", /* 406 */
84 "Proxy Authentication Required", /* 407 */
85 "Request Time-out", /* 408 */
86 "Conflict", /* 409 */
87 "Gone", /* 410 */
88 "Length Required", /* 411 */
89 "Precondition Failed", /* 412 */
90 "Request Entity Too Large", /* 413 */
91 "Request-URI Too Large", /* 414 */
92 "Unsupported Media Type", /* 415 */
93 "Request range not satisfiable", /* 416 */
94 "Expectation Failed" /* 417 */
95 };
97 /* HTTP 5xx error strings */
98 const char *http_msg5xx[] = {
99 "Internal Server Error", /* 500 */
100 "Not Implemented", /* 501 */
101 "Bad Gateway", /* 502 */
102 "Service Unavailable", /* 503 */
103 "Gateway Time-out", /* 504 */
104 "HTTP Version not supported" /* 505 */
105 };
107 #endif /* HTTP_H_ */