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