Rtos API example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers httpd_structs.h Source File

httpd_structs.h

00001 #ifndef LWIP_HTTPD_STRUCTS_H
00002 #define LWIP_HTTPD_STRUCTS_H
00003 
00004 #include "lwip/apps/httpd.h"
00005 
00006 #if LWIP_HTTPD_DYNAMIC_HEADERS
00007 /** This struct is used for a list of HTTP header strings for various
00008  * filename extensions. */
00009 typedef struct
00010 {
00011   const char *extension;
00012   const char *content_type;
00013 } tHTTPHeader;
00014 
00015 /** A list of strings used in HTTP headers (see RFC 1945 HTTP/1.0 and
00016  * RFC 2616 HTTP/1.1 for header field definitions) */
00017 static const char * const g_psHTTPHeaderStrings[] =
00018 {
00019  "HTTP/1.0 200 OK\r\n",
00020  "HTTP/1.0 404 File not found\r\n",
00021  "HTTP/1.0 400 Bad Request\r\n",
00022  "HTTP/1.0 501 Not Implemented\r\n",
00023  "HTTP/1.1 200 OK\r\n",
00024  "HTTP/1.1 404 File not found\r\n",
00025  "HTTP/1.1 400 Bad Request\r\n",
00026  "HTTP/1.1 501 Not Implemented\r\n",
00027  "Content-Length: ",
00028  "Connection: Close\r\n",
00029  "Connection: keep-alive\r\n",
00030  "Connection: keep-alive\r\nContent-Length: ",
00031  "Server: "HTTPD_SERVER_AGENT"\r\n",
00032  "\r\n<html><body><h2>404: The requested file cannot be found.</h2></body></html>\r\n"
00033 #if LWIP_HTTPD_SUPPORT_11_KEEPALIVE
00034  ,"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"
00035 #endif
00036 };
00037 
00038 /* Indexes into the g_psHTTPHeaderStrings array */
00039 #define HTTP_HDR_OK             0 /* 200 OK */
00040 #define HTTP_HDR_NOT_FOUND      1 /* 404 File not found */
00041 #define HTTP_HDR_BAD_REQUEST    2 /* 400 Bad request */
00042 #define HTTP_HDR_NOT_IMPL       3 /* 501 Not Implemented */
00043 #define HTTP_HDR_OK_11          4 /* 200 OK */
00044 #define HTTP_HDR_NOT_FOUND_11   5 /* 404 File not found */
00045 #define HTTP_HDR_BAD_REQUEST_11 6 /* 400 Bad request */
00046 #define HTTP_HDR_NOT_IMPL_11    7 /* 501 Not Implemented */
00047 #define HTTP_HDR_CONTENT_LENGTH 8 /* Content-Length: (HTTP 1.0)*/
00048 #define HTTP_HDR_CONN_CLOSE     9 /* Connection: Close (HTTP 1.1) */
00049 #define HTTP_HDR_CONN_KEEPALIVE 10 /* Connection: keep-alive (HTTP 1.1) */
00050 #define HTTP_HDR_KEEPALIVE_LEN  11 /* Connection: keep-alive + Content-Length: (HTTP 1.1)*/
00051 #define HTTP_HDR_SERVER         12 /* Server: HTTPD_SERVER_AGENT */
00052 #define DEFAULT_404_HTML        13 /* default 404 body */
00053 #if LWIP_HTTPD_SUPPORT_11_KEEPALIVE
00054 #define DEFAULT_404_HTML_PERSISTENT 14 /* default 404 body, but including Connection: keep-alive */
00055 #endif
00056 
00057 
00058 #define HTTP_HDR_HTML           "Content-type: text/html\r\n\r\n"
00059 #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"
00060 #define HTTP_HDR_GIF            "Content-type: image/gif\r\n\r\n"
00061 #define HTTP_HDR_PNG            "Content-type: image/png\r\n\r\n"
00062 #define HTTP_HDR_JPG            "Content-type: image/jpeg\r\n\r\n"
00063 #define HTTP_HDR_BMP            "Content-type: image/bmp\r\n\r\n"
00064 #define HTTP_HDR_ICO            "Content-type: image/x-icon\r\n\r\n"
00065 #define HTTP_HDR_APP            "Content-type: application/octet-stream\r\n\r\n"
00066 #define HTTP_HDR_JS             "Content-type: application/javascript\r\n\r\n"
00067 #define HTTP_HDR_RA             "Content-type: application/javascript\r\n\r\n"
00068 #define HTTP_HDR_CSS            "Content-type: text/css\r\n\r\n"
00069 #define HTTP_HDR_SWF            "Content-type: application/x-shockwave-flash\r\n\r\n"
00070 #define HTTP_HDR_XML            "Content-type: text/xml\r\n\r\n"
00071 #define HTTP_HDR_PDF            "Content-type: application/pdf\r\n\r\n"
00072 #define HTTP_HDR_JSON           "Content-type: application/json\r\n\r\n"
00073 
00074 #define HTTP_HDR_DEFAULT_TYPE   "Content-type: text/plain\r\n\r\n"
00075 
00076 /** A list of extension-to-HTTP header strings (see outdated RFC 1700 MEDIA TYPES
00077  * and http://www.iana.org/assignments/media-types for registered content types
00078  * and subtypes) */
00079 static const tHTTPHeader g_psHTTPHeaders[] =
00080 {
00081  { "html", HTTP_HDR_HTML},
00082  { "htm",  HTTP_HDR_HTML},
00083  { "shtml",HTTP_HDR_SSI},
00084  { "shtm", HTTP_HDR_SSI},
00085  { "ssi",  HTTP_HDR_SSI},
00086  { "gif",  HTTP_HDR_GIF},
00087  { "png",  HTTP_HDR_PNG},
00088  { "jpg",  HTTP_HDR_JPG},
00089  { "bmp",  HTTP_HDR_BMP},
00090  { "ico",  HTTP_HDR_ICO},
00091  { "class",HTTP_HDR_APP},
00092  { "cls",  HTTP_HDR_APP},
00093  { "js",   HTTP_HDR_JS},
00094  { "ram",  HTTP_HDR_RA},
00095  { "css",  HTTP_HDR_CSS},
00096  { "swf",  HTTP_HDR_SWF},
00097  { "xml",  HTTP_HDR_XML},
00098  { "xsl",  HTTP_HDR_XML},
00099  { "pdf",  HTTP_HDR_PDF},
00100  { "json", HTTP_HDR_JSON}
00101 };
00102 
00103 #define NUM_HTTP_HEADERS (sizeof(g_psHTTPHeaders) / sizeof(tHTTPHeader))
00104 
00105 #endif /* LWIP_HTTPD_DYNAMIC_HEADERS */
00106 
00107 #if LWIP_HTTPD_SSI
00108 static const char * const g_pcSSIExtensions[] = {
00109   ".shtml", ".shtm", ".ssi", ".xml"
00110 };
00111 #define NUM_SHTML_EXTENSIONS (sizeof(g_pcSSIExtensions) / sizeof(const char *))
00112 #endif /* LWIP_HTTPD_SSI */
00113 
00114 #endif /* LWIP_HTTPD_STRUCTS_H */