Kinetis SDK v.1.2 Demo Applications User's Guide  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
httpd_structs.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25  * OF SUCH DAMAGE.
26  *
27  * This file is part of the lwIP TCP/IP stack.
28  *
29  * Author: Adam Dunkels <adam@sics.se>
30  *
31  */
32 
33 #ifndef __HTTPD_STRUCTS_H__
34 #define __HTTPD_STRUCTS_H__
35 
37 // Includes
39 
40 #include "httpd.h"
41 
43 // Definitions
45 
46 // This string is passed in the HTTP header as "Server: "
47 #ifndef HTTPD_SERVER_AGENT
48 #define HTTPD_SERVER_AGENT "lwIP/1.3.1 (http://savannah.nongnu.org/projects/lwip)"
49 #endif
50 
51 // Set this to 1 if you want to include code that creates HTTP headers
52 // at runtime. Default is off: HTTP headers are then created statically
53 // by the makefsdata tool. Static headers mean smaller code size, but
54 // the (readonly) fsdata will grow a bit as every file includes the HTTP header.
55 #ifndef LWIP_HTTPD_DYNAMIC_HEADERS
56 #define LWIP_HTTPD_DYNAMIC_HEADERS 0
57 #endif
58 
59 
60 #if LWIP_HTTPD_DYNAMIC_HEADERS
61 // This struct is used for a list of HTTP header strings for various filename extensions.
62 typedef struct
63 {
64  const char *extension;
65  int headerIndex;
66 } tHTTPHeader;
67 
68 // A list of strings used in HTTP headers
69 static const char * const g_psHTTPHeaderStrings[] =
70 {
71  "Content-type: text/html\r\n\r\n",
72  "Content-type: text/html\r\nExpires: Fri, 10 Apr 2008 14:00:00 GMT\r\nPragma: no-cache\r\n\r\n",
73  "Content-type: image/gif\r\n\r\n",
74  "Content-type: image/png\r\n\r\n",
75  "Content-type: image/jpeg\r\n\r\n",
76  "Content-type: image/bmp\r\n\r\n",
77  "Content-type: image/x-icon\r\n\r\n",
78  "Content-type: application/octet-stream\r\n\r\n",
79  "Content-type: application/x-javascript\r\n\r\n",
80  "Content-type: application/x-javascript\r\n\r\n",
81  "Content-type: text/css\r\n\r\n",
82  "Content-type: application/x-shockwave-flash\r\n\r\n",
83  "Content-type: text/xml\r\n\r\n",
84  "Content-type: text/plain\r\n\r\n",
85  "HTTP/1.0 200 OK\r\n",
86  "HTTP/1.0 404 File not found\r\n",
87  "HTTP/1.0 400 Bad Request\r\n",
88  "HTTP/1.0 501 Not Implemented\r\n",
89  "HTTP/1.1 200 OK\r\n",
90  "HTTP/1.1 404 File not found\r\n",
91  "HTTP/1.1 400 Bad Request\r\n",
92  "HTTP/1.1 501 Not Implemented\r\n",
93  "Content-Length: ",
94  "Connection: Close\r\n",
95  "Connection: keep-alive\r\n",
96  "Server: "HTTPD_SERVER_AGENT"\r\n",
97  "\r\n<html><body><h2>404: The requested file cannot be found.</h2></body></html>\r\n"
98 };
99 
100 // Indexes into the g_psHTTPHeaderStrings array
101 #define HTTP_HDR_HTML 0 // text/html
102 #define HTTP_HDR_SSI 1 // text/html Expires...
103 #define HTTP_HDR_GIF 2 // image/gif
104 #define HTTP_HDR_PNG 3 // image/png
105 #define HTTP_HDR_JPG 4 // image/jpeg
106 #define HTTP_HDR_BMP 5 // image/bmp
107 #define HTTP_HDR_ICO 6 // image/x-icon
108 #define HTTP_HDR_APP 7 // application/octet-stream
109 #define HTTP_HDR_JS 8 // application/x-javascript
110 #define HTTP_HDR_RA 9 // application/x-javascript
111 #define HTTP_HDR_CSS 10 // text/css
112 #define HTTP_HDR_SWF 11 // application/x-shockwave-flash
113 #define HTTP_HDR_XML 12 // text/xml
114 #define HTTP_HDR_DEFAULT_TYPE 13 // text/plain
115 #define HTTP_HDR_OK 14 // 200 OK */
116 #define HTTP_HDR_NOT_FOUND 15 // 404 File not found
117 #define HTTP_HDR_BAD_REQUEST 16 // 400 Bad request
118 #define HTTP_HDR_NOT_IMPL 17 // 501 Not Implemented
119 #define HTTP_HDR_OK_11 18 // 200 OK
120 #define HTTP_HDR_NOT_FOUND_11 19 // 404 File not found
121 #define HTTP_HDR_BAD_REQUEST_11 20 // 400 Bad request
122 #define HTTP_HDR_NOT_IMPL_11 21 // 501 Not Implemented
123 #define HTTP_HDR_CONTENT_LENGTH 22 // Content-Length: (HTTP 1.1)
124 #define HTTP_HDR_CONN_CLOSE 23 // Connection: Close (HTTP 1.1)
125 #define HTTP_HDR_CONN_KEEPALIVE 24 // Connection: keep-alive (HTTP 1.1)
126 #define HTTP_HDR_SERVER 25 // Server: HTTPD_SERVER_AGENT
127 #define DEFAULT_404_HTML 26 // default 404 body
128 
129 // A list of extension-to-HTTP header strings
130 const static tHTTPHeader g_psHTTPHeaders[] =
131 {
132  { "html", HTTP_HDR_HTML},
133  { "htm", HTTP_HDR_HTML},
134  { "shtml",HTTP_HDR_SSI},
135  { "shtm", HTTP_HDR_SSI},
136  { "ssi", HTTP_HDR_SSI},
137  { "gif", HTTP_HDR_GIF},
138  { "png", HTTP_HDR_PNG},
139  { "jpg", HTTP_HDR_JPG},
140  { "bmp", HTTP_HDR_BMP},
141  { "ico", HTTP_HDR_ICO},
142  { "class",HTTP_HDR_APP},
143  { "cls", HTTP_HDR_APP},
144  { "js", HTTP_HDR_JS},
145  { "ram", HTTP_HDR_RA},
146  { "css", HTTP_HDR_CSS},
147  { "swf", HTTP_HDR_SWF},
148  { "xml", HTTP_HDR_XML},
149  { "xsl", HTTP_HDR_XML}
150 };
151 
152 #define NUM_HTTP_HEADERS (sizeof(g_psHTTPHeaders) / sizeof(tHTTPHeader))
153 
154 #endif // LWIP_HTTPD_DYNAMIC_HEADERS
155 
156 #if LWIP_HTTPD_SSI
157 static const char * const g_pcSSIExtensions[] = {
158  ".shtml", ".shtm", ".ssi", ".xml"
159 };
160 #define NUM_SHTML_EXTENSIONS (sizeof(g_pcSSIExtensions) / sizeof(const char *))
161 #endif // LWIP_HTTPD_SSI
162 
163 #endif // __HTTPD_STRUCTS_H__
#define HTTPD_SERVER_AGENT
Definition: httpd_structs.h:48