1 | #ifndef LWIP_HTTPD_STRUCTS_H
|
---|
2 | #define LWIP_HTTPD_STRUCTS_H
|
---|
3 |
|
---|
4 | #include "lwip/apps/httpd.h"
|
---|
5 |
|
---|
6 | #if LWIP_HTTPD_DYNAMIC_HEADERS
|
---|
7 | /** This struct is used for a list of HTTP header strings for various
|
---|
8 | * filename extensions. */
|
---|
9 | typedef struct {
|
---|
10 | const char *extension;
|
---|
11 | const char *content_type;
|
---|
12 | } tHTTPHeader;
|
---|
13 |
|
---|
14 | /** A list of strings used in HTTP headers (see RFC 1945 HTTP/1.0 and
|
---|
15 | * RFC 2616 HTTP/1.1 for header field definitions) */
|
---|
16 | static const char *const g_psHTTPHeaderStrings[] = {
|
---|
17 | "HTTP/1.0 200 OK\r\n",
|
---|
18 | "HTTP/1.0 404 File not found\r\n",
|
---|
19 | "HTTP/1.0 400 Bad Request\r\n",
|
---|
20 | "HTTP/1.0 501 Not Implemented\r\n",
|
---|
21 | "HTTP/1.1 200 OK\r\n",
|
---|
22 | "HTTP/1.1 404 File not found\r\n",
|
---|
23 | "HTTP/1.1 400 Bad Request\r\n",
|
---|
24 | "HTTP/1.1 501 Not Implemented\r\n",
|
---|
25 | "Content-Length: ",
|
---|
26 | "Connection: Close\r\n",
|
---|
27 | "Connection: keep-alive\r\n",
|
---|
28 | "Connection: keep-alive\r\nContent-Length: ",
|
---|
29 | "Server: "HTTPD_SERVER_AGENT"\r\n",
|
---|
30 | "\r\n<html><body><h2>404: The requested file cannot be found.</h2></body></html>\r\n"
|
---|
31 | #if LWIP_HTTPD_SUPPORT_11_KEEPALIVE
|
---|
32 | , "Connection: keep-alive\r\nContent-Length: 77\r\n\r\n<html><body><h2>404: The requested file cannot be found.</h2></body></html>\r\n"
|
---|
33 | #endif
|
---|
34 | };
|
---|
35 |
|
---|
36 | /* Indexes into the g_psHTTPHeaderStrings array */
|
---|
37 | #define HTTP_HDR_OK 0 /* 200 OK */
|
---|
38 | #define HTTP_HDR_NOT_FOUND 1 /* 404 File not found */
|
---|
39 | #define HTTP_HDR_BAD_REQUEST 2 /* 400 Bad request */
|
---|
40 | #define HTTP_HDR_NOT_IMPL 3 /* 501 Not Implemented */
|
---|
41 | #define HTTP_HDR_OK_11 4 /* 200 OK */
|
---|
42 | #define HTTP_HDR_NOT_FOUND_11 5 /* 404 File not found */
|
---|
43 | #define HTTP_HDR_BAD_REQUEST_11 6 /* 400 Bad request */
|
---|
44 | #define HTTP_HDR_NOT_IMPL_11 7 /* 501 Not Implemented */
|
---|
45 | #define HTTP_HDR_CONTENT_LENGTH 8 /* Content-Length: (HTTP 1.0)*/
|
---|
46 | #define HTTP_HDR_CONN_CLOSE 9 /* Connection: Close (HTTP 1.1) */
|
---|
47 | #define HTTP_HDR_CONN_KEEPALIVE 10 /* Connection: keep-alive (HTTP 1.1) */
|
---|
48 | #define HTTP_HDR_KEEPALIVE_LEN 11 /* Connection: keep-alive + Content-Length: (HTTP 1.1)*/
|
---|
49 | #define HTTP_HDR_SERVER 12 /* Server: HTTPD_SERVER_AGENT */
|
---|
50 | #define DEFAULT_404_HTML 13 /* default 404 body */
|
---|
51 | #if LWIP_HTTPD_SUPPORT_11_KEEPALIVE
|
---|
52 | #define DEFAULT_404_HTML_PERSISTENT 14 /* default 404 body, but including Connection: keep-alive */
|
---|
53 | #endif
|
---|
54 |
|
---|
55 | #define HTTP_CONTENT_TYPE(contenttype) "Content-Type: "contenttype"\r\n\r\n"
|
---|
56 | #define HTTP_CONTENT_TYPE_ENCODING(contenttype, encoding) "Content-Type: "contenttype"\r\nContent-Encoding: "encoding"\r\n\r\n"
|
---|
57 |
|
---|
58 | #define HTTP_HDR_HTML HTTP_CONTENT_TYPE("text/html")
|
---|
59 | #define HTTP_HDR_SSI HTTP_CONTENT_TYPE("text/html\r\nExpires: Fri, 10 Apr 2008 14:00:00 GMT\r\nPragma: no-cache")
|
---|
60 | #define HTTP_HDR_GIF HTTP_CONTENT_TYPE("image/gif")
|
---|
61 | #define HTTP_HDR_PNG HTTP_CONTENT_TYPE("image/png")
|
---|
62 | #define HTTP_HDR_JPG HTTP_CONTENT_TYPE("image/jpeg")
|
---|
63 | #define HTTP_HDR_BMP HTTP_CONTENT_TYPE("image/bmp")
|
---|
64 | #define HTTP_HDR_ICO HTTP_CONTENT_TYPE("image/x-icon")
|
---|
65 | #define HTTP_HDR_APP HTTP_CONTENT_TYPE("application/octet-stream")
|
---|
66 | #define HTTP_HDR_JS HTTP_CONTENT_TYPE("application/javascript")
|
---|
67 | #define HTTP_HDR_RA HTTP_CONTENT_TYPE("application/javascript")
|
---|
68 | #define HTTP_HDR_CSS HTTP_CONTENT_TYPE("text/css")
|
---|
69 | #define HTTP_HDR_SWF HTTP_CONTENT_TYPE("application/x-shockwave-flash")
|
---|
70 | #define HTTP_HDR_XML HTTP_CONTENT_TYPE("text/xml")
|
---|
71 | #define HTTP_HDR_PDF HTTP_CONTENT_TYPE("application/pdf")
|
---|
72 | #define HTTP_HDR_JSON HTTP_CONTENT_TYPE("application/json")
|
---|
73 | #define HTTP_HDR_CSV HTTP_CONTENT_TYPE("text/csv")
|
---|
74 | #define HTTP_HDR_TSV HTTP_CONTENT_TYPE("text/tsv")
|
---|
75 | #define HTTP_HDR_SVG HTTP_CONTENT_TYPE("image/svg+xml")
|
---|
76 | #define HTTP_HDR_SVGZ HTTP_CONTENT_TYPE_ENCODING("image/svg+xml", "gzip")
|
---|
77 |
|
---|
78 | #define HTTP_HDR_DEFAULT_TYPE HTTP_CONTENT_TYPE("text/plain")
|
---|
79 |
|
---|
80 | /** A list of extension-to-HTTP header strings (see outdated RFC 1700 MEDIA TYPES
|
---|
81 | * and http://www.iana.org/assignments/media-types for registered content types
|
---|
82 | * and subtypes) */
|
---|
83 | static const tHTTPHeader g_psHTTPHeaders[] = {
|
---|
84 | { "html", HTTP_HDR_HTML},
|
---|
85 | { "htm", HTTP_HDR_HTML},
|
---|
86 | { "shtml", HTTP_HDR_SSI},
|
---|
87 | { "shtm", HTTP_HDR_SSI},
|
---|
88 | { "ssi", HTTP_HDR_SSI},
|
---|
89 | { "gif", HTTP_HDR_GIF},
|
---|
90 | { "png", HTTP_HDR_PNG},
|
---|
91 | { "jpg", HTTP_HDR_JPG},
|
---|
92 | { "bmp", HTTP_HDR_BMP},
|
---|
93 | { "ico", HTTP_HDR_ICO},
|
---|
94 | { "class", HTTP_HDR_APP},
|
---|
95 | { "cls", HTTP_HDR_APP},
|
---|
96 | { "js", HTTP_HDR_JS},
|
---|
97 | { "ram", HTTP_HDR_RA},
|
---|
98 | { "css", HTTP_HDR_CSS},
|
---|
99 | { "swf", HTTP_HDR_SWF},
|
---|
100 | { "xml", HTTP_HDR_XML},
|
---|
101 | { "xsl", HTTP_HDR_XML},
|
---|
102 | { "pdf", HTTP_HDR_PDF},
|
---|
103 | { "json", HTTP_HDR_JSON}
|
---|
104 | #ifdef HTTPD_ADDITIONAL_CONTENT_TYPES
|
---|
105 | /* If you need to add content types not listed here:
|
---|
106 | * #define HTTPD_ADDITIONAL_CONTENT_TYPES {"ct1", HTTP_CONTENT_TYPE("text/ct1")}, {"exe", HTTP_CONTENT_TYPE("application/exe")}
|
---|
107 | */
|
---|
108 | , HTTPD_ADDITIONAL_CONTENT_TYPES
|
---|
109 | #endif
|
---|
110 | };
|
---|
111 |
|
---|
112 | #define NUM_HTTP_HEADERS LWIP_ARRAYSIZE(g_psHTTPHeaders)
|
---|
113 |
|
---|
114 | #endif /* LWIP_HTTPD_DYNAMIC_HEADERS */
|
---|
115 |
|
---|
116 | #if LWIP_HTTPD_SSI
|
---|
117 | static const char *const g_pcSSIExtensions[] = {
|
---|
118 | ".shtml", ".shtm", ".ssi", ".xml", ".json"
|
---|
119 | };
|
---|
120 | #define NUM_SHTML_EXTENSIONS LWIP_ARRAYSIZE(g_pcSSIExtensions)
|
---|
121 | #endif /* LWIP_HTTPD_SSI */
|
---|
122 |
|
---|
123 | #endif /* LWIP_HTTPD_STRUCTS_H */
|
---|