httpd_opts.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. /**
  2. * @file
  3. * HTTP server options list
  4. */
  5. /*
  6. * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
  7. * All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without modification,
  10. * are permitted provided that the following conditions are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright notice,
  15. * this list of conditions and the following disclaimer in the documentation
  16. * and/or other materials provided with the distribution.
  17. * 3. The name of the author may not be used to endorse or promote products
  18. * derived from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  21. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  22. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
  23. * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  24. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
  25. * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  27. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  28. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  29. * OF SUCH DAMAGE.
  30. *
  31. * This file is part of the lwIP TCP/IP stack.
  32. *
  33. * Author: Adam Dunkels <adam@sics.se>
  34. *
  35. * This version of the file has been modified by Texas Instruments to offer
  36. * simple server-side-include (SSI) and Common Gateway Interface (CGI)
  37. * capability.
  38. */
  39. #ifndef LWIP_HDR_APPS_HTTPD_OPTS_H
  40. #define LWIP_HDR_APPS_HTTPD_OPTS_H
  41. #include "lwip/opt.h"
  42. /**
  43. * @defgroup httpd_opts Options
  44. * @ingroup httpd
  45. * @{
  46. */
  47. /** Set this to 1 to support CGI (old style) */
  48. #if !defined LWIP_HTTPD_CGI || defined __DOXYGEN__
  49. #define LWIP_HTTPD_CGI 0
  50. #endif
  51. /** Set this to 1 to support CGI (new style) */
  52. #if !defined LWIP_HTTPD_CGI_SSI || defined __DOXYGEN__
  53. #define LWIP_HTTPD_CGI_SSI 0
  54. #endif
  55. /** Set this to 1 to support SSI (Server-Side-Includes) */
  56. #if !defined LWIP_HTTPD_SSI || defined __DOXYGEN__
  57. #define LWIP_HTTPD_SSI 0
  58. #endif
  59. /** Set this to 1 to implement an SSI tag handler callback that gets a const char*
  60. * to the tag (instead of an index into a pre-registered array of known tags) */
  61. #if !defined LWIP_HTTPD_SSI_RAW || defined __DOXYGEN__
  62. #define LWIP_HTTPD_SSI_RAW 0
  63. #endif
  64. /** Set this to 1 to support HTTP POST */
  65. #if !defined LWIP_HTTPD_SUPPORT_POST || defined __DOXYGEN__
  66. #define LWIP_HTTPD_SUPPORT_POST 0
  67. #endif
  68. /* The maximum number of parameters that the CGI handler can be sent. */
  69. #if !defined LWIP_HTTPD_MAX_CGI_PARAMETERS || defined __DOXYGEN__
  70. #define LWIP_HTTPD_MAX_CGI_PARAMETERS 16
  71. #endif
  72. /** LWIP_HTTPD_SSI_MULTIPART==1: SSI handler function is called with 2 more
  73. * arguments indicating a counter for insert string that are too long to be
  74. * inserted at once: the SSI handler function must then set 'next_tag_part'
  75. * which will be passed back to it in the next call. */
  76. #if !defined LWIP_HTTPD_SSI_MULTIPART || defined __DOXYGEN__
  77. #define LWIP_HTTPD_SSI_MULTIPART 0
  78. #endif
  79. /* The maximum length of the string comprising the tag name */
  80. #if !defined LWIP_HTTPD_MAX_TAG_NAME_LEN || defined __DOXYGEN__
  81. #define LWIP_HTTPD_MAX_TAG_NAME_LEN 8
  82. #endif
  83. /* The maximum length of string that can be returned to replace any given tag */
  84. #if !defined LWIP_HTTPD_MAX_TAG_INSERT_LEN || defined __DOXYGEN__
  85. #define LWIP_HTTPD_MAX_TAG_INSERT_LEN 192
  86. #endif
  87. #if !defined LWIP_HTTPD_POST_MANUAL_WND || defined __DOXYGEN__
  88. #define LWIP_HTTPD_POST_MANUAL_WND 0
  89. #endif
  90. /** This string is passed in the HTTP header as "Server: " */
  91. #if !defined HTTPD_SERVER_AGENT || defined __DOXYGEN__
  92. #define HTTPD_SERVER_AGENT "lwIP/" LWIP_VERSION_STRING " (http://savannah.nongnu.org/projects/lwip)"
  93. #endif
  94. /** Set this to 1 if you want to include code that creates HTTP headers
  95. * at runtime. Default is off: HTTP headers are then created statically
  96. * by the makefsdata tool. Static headers mean smaller code size, but
  97. * the (readonly) fsdata will grow a bit as every file includes the HTTP
  98. * header. */
  99. #if !defined LWIP_HTTPD_DYNAMIC_HEADERS || defined __DOXYGEN__
  100. #define LWIP_HTTPD_DYNAMIC_HEADERS 0
  101. #endif
  102. #if !defined HTTPD_DEBUG || defined __DOXYGEN__
  103. #define HTTPD_DEBUG LWIP_DBG_OFF
  104. #endif
  105. /** Set this to 1 to use a memp pool for allocating
  106. * struct http_state instead of the heap.
  107. */
  108. #if !defined HTTPD_USE_MEM_POOL || defined __DOXYGEN__
  109. #define HTTPD_USE_MEM_POOL 0
  110. #endif
  111. /** The server port for HTTPD to use */
  112. #if !defined HTTPD_SERVER_PORT || defined __DOXYGEN__
  113. #define HTTPD_SERVER_PORT 80
  114. #endif
  115. /** Maximum retries before the connection is aborted/closed.
  116. * - number of times pcb->poll is called -> default is 4*500ms = 2s;
  117. * - reset when pcb->sent is called
  118. */
  119. #if !defined HTTPD_MAX_RETRIES || defined __DOXYGEN__
  120. #define HTTPD_MAX_RETRIES 4
  121. #endif
  122. /** The poll delay is X*500ms */
  123. #if !defined HTTPD_POLL_INTERVAL || defined __DOXYGEN__
  124. #define HTTPD_POLL_INTERVAL 4
  125. #endif
  126. /** Priority for tcp pcbs created by HTTPD (very low by default).
  127. * Lower priorities get killed first when running out of memory.
  128. */
  129. #if !defined HTTPD_TCP_PRIO || defined __DOXYGEN__
  130. #define HTTPD_TCP_PRIO TCP_PRIO_MIN
  131. #endif
  132. /** Set this to 1 to enable timing each file sent */
  133. #if !defined LWIP_HTTPD_TIMING || defined __DOXYGEN__
  134. #define LWIP_HTTPD_TIMING 0
  135. #endif
  136. /** Set this to 1 to enable timing each file sent */
  137. #if !defined HTTPD_DEBUG_TIMING || defined __DOXYGEN__
  138. #define HTTPD_DEBUG_TIMING LWIP_DBG_OFF
  139. #endif
  140. /** Set this to one to show error pages when parsing a request fails instead
  141. of simply closing the connection. */
  142. #if !defined LWIP_HTTPD_SUPPORT_EXTSTATUS || defined __DOXYGEN__
  143. #define LWIP_HTTPD_SUPPORT_EXTSTATUS 0
  144. #endif
  145. /** Set this to 0 to drop support for HTTP/0.9 clients (to save some bytes) */
  146. #if !defined LWIP_HTTPD_SUPPORT_V09 || defined __DOXYGEN__
  147. #define LWIP_HTTPD_SUPPORT_V09 1
  148. #endif
  149. /** Set this to 1 to enable HTTP/1.1 persistent connections.
  150. * ATTENTION: If the generated file system includes HTTP headers, these must
  151. * include the "Connection: keep-alive" header (pass argument "-11" to makefsdata).
  152. */
  153. #if !defined LWIP_HTTPD_SUPPORT_11_KEEPALIVE || defined __DOXYGEN__
  154. #define LWIP_HTTPD_SUPPORT_11_KEEPALIVE 0
  155. #endif
  156. /** Set this to 1 to support HTTP request coming in in multiple packets/pbufs */
  157. #if !defined LWIP_HTTPD_SUPPORT_REQUESTLIST || defined __DOXYGEN__
  158. #define LWIP_HTTPD_SUPPORT_REQUESTLIST 1
  159. #endif
  160. #if LWIP_HTTPD_SUPPORT_REQUESTLIST
  161. /** Number of rx pbufs to enqueue to parse an incoming request (up to the first
  162. newline) */
  163. #if !defined LWIP_HTTPD_REQ_QUEUELEN || defined __DOXYGEN__
  164. #define LWIP_HTTPD_REQ_QUEUELEN 5
  165. #endif
  166. /** Number of (TCP payload-) bytes (in pbufs) to enqueue to parse and incoming
  167. request (up to the first double-newline) */
  168. #if !defined LWIP_HTTPD_REQ_BUFSIZE || defined __DOXYGEN__
  169. #define LWIP_HTTPD_REQ_BUFSIZE LWIP_HTTPD_MAX_REQ_LENGTH
  170. #endif
  171. /** Defines the maximum length of a HTTP request line (up to the first CRLF,
  172. copied from pbuf into this a global buffer when pbuf- or packet-queues
  173. are received - otherwise the input pbuf is used directly) */
  174. #if !defined LWIP_HTTPD_MAX_REQ_LENGTH || defined __DOXYGEN__
  175. #define LWIP_HTTPD_MAX_REQ_LENGTH LWIP_MIN(1023, (LWIP_HTTPD_REQ_QUEUELEN * PBUF_POOL_BUFSIZE))
  176. #endif
  177. #endif /* LWIP_HTTPD_SUPPORT_REQUESTLIST */
  178. /** This is the size of a static buffer used when URIs end with '/'.
  179. * In this buffer, the directory requested is concatenated with all the
  180. * configured default file names.
  181. * Set to 0 to disable checking default filenames on non-root directories.
  182. */
  183. #if !defined LWIP_HTTPD_MAX_REQUEST_URI_LEN || defined __DOXYGEN__
  184. #define LWIP_HTTPD_MAX_REQUEST_URI_LEN 63
  185. #endif
  186. /** Maximum length of the filename to send as response to a POST request,
  187. * filled in by the application when a POST is finished.
  188. */
  189. #if !defined LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN || defined __DOXYGEN__
  190. #define LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN 63
  191. #endif
  192. /** Set this to 0 to not send the SSI tag (default is on, so the tag will
  193. * be sent in the HTML page */
  194. #if !defined LWIP_HTTPD_SSI_INCLUDE_TAG || defined __DOXYGEN__
  195. #define LWIP_HTTPD_SSI_INCLUDE_TAG 1
  196. #endif
  197. /** Set this to 1 to call tcp_abort when tcp_close fails with memory error.
  198. * This can be used to prevent consuming all memory in situations where the
  199. * HTTP server has low priority compared to other communication. */
  200. #if !defined LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR || defined __DOXYGEN__
  201. #define LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR 0
  202. #endif
  203. /** Set this to 1 to kill the oldest connection when running out of
  204. * memory for 'struct http_state' or 'struct http_ssi_state'.
  205. * ATTENTION: This puts all connections on a linked list, so may be kind of slow.
  206. */
  207. #if !defined LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED || defined __DOXYGEN__
  208. #define LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED 0
  209. #endif
  210. /** Set this to 1 to send URIs without extension without headers
  211. * (who uses this at all??) */
  212. #if !defined LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI || defined __DOXYGEN__
  213. #define LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI 0
  214. #endif
  215. /** Default: Tags are sent from struct http_state and are therefore volatile */
  216. #if !defined HTTP_IS_TAG_VOLATILE || defined __DOXYGEN__
  217. #define HTTP_IS_TAG_VOLATILE(ptr) TCP_WRITE_FLAG_COPY
  218. #endif
  219. /* By default, the httpd is limited to send 2*pcb->mss to keep resource usage low
  220. when http is not an important protocol in the device. */
  221. #if !defined HTTPD_LIMIT_SENDING_TO_2MSS || defined __DOXYGEN__
  222. #define HTTPD_LIMIT_SENDING_TO_2MSS 1
  223. #endif
  224. /* Define this to a function that returns the maximum amount of data to enqueue.
  225. The function have this signature: u16_t fn(struct tcp_pcb* pcb); */
  226. #if !defined HTTPD_MAX_WRITE_LEN || defined __DOXYGEN__
  227. #if HTTPD_LIMIT_SENDING_TO_2MSS
  228. #define HTTPD_MAX_WRITE_LEN(pcb) (2 * tcp_mss(pcb))
  229. #endif
  230. #endif
  231. /*------------------- FS OPTIONS -------------------*/
  232. /** Set this to 1 and provide the functions:
  233. * - "int fs_open_custom(struct fs_file *file, const char *name)"
  234. * Called first for every opened file to allow opening files
  235. * that are not included in fsdata(_custom).c
  236. * - "void fs_close_custom(struct fs_file *file)"
  237. * Called to free resources allocated by fs_open_custom().
  238. */
  239. #if !defined LWIP_HTTPD_CUSTOM_FILES || defined __DOXYGEN__
  240. #define LWIP_HTTPD_CUSTOM_FILES 0
  241. #endif
  242. /** Set this to 1 to support fs_read() to dynamically read file data.
  243. * Without this (default=off), only one-block files are supported,
  244. * and the contents must be ready after fs_open().
  245. */
  246. #if !defined LWIP_HTTPD_DYNAMIC_FILE_READ || defined __DOXYGEN__
  247. #define LWIP_HTTPD_DYNAMIC_FILE_READ 0
  248. #endif
  249. /** Set this to 1 to include an application state argument per file
  250. * that is opened. This allows to keep a state per connection/file.
  251. */
  252. #if !defined LWIP_HTTPD_FILE_STATE || defined __DOXYGEN__
  253. #define LWIP_HTTPD_FILE_STATE 0
  254. #endif
  255. /** HTTPD_PRECALCULATED_CHECKSUM==1: include precompiled checksums for
  256. * predefined (MSS-sized) chunks of the files to prevent having to calculate
  257. * the checksums at runtime. */
  258. #if !defined HTTPD_PRECALCULATED_CHECKSUM || defined __DOXYGEN__
  259. #define HTTPD_PRECALCULATED_CHECKSUM 0
  260. #endif
  261. /** LWIP_HTTPD_FS_ASYNC_READ==1: support asynchronous read operations
  262. * (fs_read_async returns FS_READ_DELAYED and calls a callback when finished).
  263. */
  264. #if !defined LWIP_HTTPD_FS_ASYNC_READ || defined __DOXYGEN__
  265. #define LWIP_HTTPD_FS_ASYNC_READ 0
  266. #endif
  267. /** Set this to 1 to include "fsdata_custom.c" instead of "fsdata.c" for the
  268. * file system (to prevent changing the file included in CVS) */
  269. #if !defined HTTPD_USE_CUSTOM_FSDATA || defined __DOXYGEN__
  270. #define HTTPD_USE_CUSTOM_FSDATA 0
  271. #endif
  272. /**
  273. * @}
  274. */
  275. #endif /* LWIP_HDR_APPS_HTTPD_OPTS_H */