Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
httpd_opts.h
00001 /** 00002 * @file 00003 * HTTP server options list 00004 */ 00005 00006 /* 00007 * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without modification, 00011 * are permitted provided that the following conditions are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. The name of the author may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00024 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00026 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00029 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00030 * OF SUCH DAMAGE. 00031 * 00032 * This file is part of the lwIP TCP/IP stack. 00033 * 00034 * Author: Adam Dunkels <adam@sics.se> 00035 * 00036 * This version of the file has been modified by Texas Instruments to offer 00037 * simple server-side-include (SSI) and Common Gateway Interface (CGI) 00038 * capability. 00039 */ 00040 00041 #ifndef LWIP_HDR_APPS_HTTPD_OPTS_H 00042 #define LWIP_HDR_APPS_HTTPD_OPTS_H 00043 00044 #include "lwip/opt.h" 00045 #include "lwip/prot/iana.h" 00046 00047 /** 00048 * @defgroup httpd_opts Options 00049 * @ingroup httpd 00050 * @{ 00051 */ 00052 00053 /** Set this to 1 to support CGI (old style). 00054 * 00055 * This old style CGI support works by registering an array of URLs and 00056 * associated CGI handler functions (@ref http_set_cgi_handlers). 00057 * This list is scanned just before fs_open is called from request handling. 00058 * The handler can return a new URL that is used internally by the httpd to 00059 * load the returned page (passed to fs_open). 00060 * 00061 * Use this CGI type e.g. to execute specific actions and return a page that 00062 * does not depend on the CGI parameters. 00063 */ 00064 #if !defined LWIP_HTTPD_CGI || defined __DOXYGEN__ 00065 #define LWIP_HTTPD_CGI 0 00066 #endif 00067 00068 /** Set this to 1 to support CGI (new style). 00069 * 00070 * This new style CGI support works by calling a global function 00071 * (@ref tCGIHandler) for all URLs that are found. fs_open is called first 00072 * and the URL can not be written by the CGI handler. Instead, this handler gets 00073 * passed the http file state, an object where it can store information derived 00074 * from the CGI URL or parameters. This file state is later passed to SSI, so 00075 * the SSI code can return data depending on CGI input. 00076 * 00077 * Use this CGI handler if you want CGI information passed on to SSI. 00078 */ 00079 #if !defined LWIP_HTTPD_CGI_SSI || defined __DOXYGEN__ 00080 #define LWIP_HTTPD_CGI_SSI 0 00081 #endif 00082 00083 /** Set this to 1 to support SSI (Server-Side-Includes) 00084 * 00085 * In contrast to other http servers, this only calls a preregistered callback 00086 * function (@see http_set_ssi_handler) for each tag (in the format of 00087 * <!--#tag-->) encountered in SSI-enabled pages. 00088 * SSI-enabled pages must have one of the predefined SSI-enabled file extensions. 00089 * All files with one of these extensions are parsed when sent. 00090 * 00091 * A downside of the current SSI implementation is that persistent connections 00092 * don't work, as the file length is not known in advance (and httpd currently 00093 * relies on the Content-Length header for persistent connections). 00094 * 00095 * To save memory, the maximum tag length is limited (@see LWIP_HTTPD_MAX_TAG_NAME_LEN). 00096 * To save memory, the maximum insertion string length is limited (@see 00097 * LWIP_HTTPD_MAX_TAG_INSERT_LEN). If this is not enought, @ref LWIP_HTTPD_SSI_MULTIPART 00098 * can be used. 00099 */ 00100 #if !defined LWIP_HTTPD_SSI || defined __DOXYGEN__ 00101 #define LWIP_HTTPD_SSI 0 00102 #endif 00103 00104 /** Set this to 1 to implement an SSI tag handler callback that gets a const char* 00105 * to the tag (instead of an index into a pre-registered array of known tags) 00106 * If this is 0, the SSI handler callback function is only called pre-registered tags. 00107 */ 00108 #if !defined LWIP_HTTPD_SSI_RAW || defined __DOXYGEN__ 00109 #define LWIP_HTTPD_SSI_RAW 0 00110 #endif 00111 00112 /** Set this to 0 to prevent parsing the file extension at runtime to decide 00113 * if a file should be scanned for SSI tags or not. 00114 * Default is 1 (file extensions are checked using the g_pcSSIExtensions array) 00115 * Set to 2 to override this runtime test function. 00116 * 00117 * This is enabled by default, but if you only use a newer version of makefsdata 00118 * supporting the "-ssi" option, this info is already present in 00119 */ 00120 #if !defined LWIP_HTTPD_SSI_BY_FILE_EXTENSION || defined __DOXYGEN__ 00121 #define LWIP_HTTPD_SSI_BY_FILE_EXTENSION 1 00122 #endif 00123 00124 /** Set this to 1 to support HTTP POST */ 00125 #if !defined LWIP_HTTPD_SUPPORT_POST || defined __DOXYGEN__ 00126 #define LWIP_HTTPD_SUPPORT_POST 0 00127 #endif 00128 00129 /* The maximum number of parameters that the CGI handler can be sent. */ 00130 #if !defined LWIP_HTTPD_MAX_CGI_PARAMETERS || defined __DOXYGEN__ 00131 #define LWIP_HTTPD_MAX_CGI_PARAMETERS 16 00132 #endif 00133 00134 /** LWIP_HTTPD_SSI_MULTIPART==1: SSI handler function is called with 2 more 00135 * arguments indicating a counter for insert string that are too long to be 00136 * inserted at once: the SSI handler function must then set 'next_tag_part' 00137 * which will be passed back to it in the next call. */ 00138 #if !defined LWIP_HTTPD_SSI_MULTIPART || defined __DOXYGEN__ 00139 #define LWIP_HTTPD_SSI_MULTIPART 0 00140 #endif 00141 00142 /* The maximum length of the string comprising the SSI tag name 00143 * ATTENTION: tags longer than this are ignored, not truncated! 00144 */ 00145 #if !defined LWIP_HTTPD_MAX_TAG_NAME_LEN || defined __DOXYGEN__ 00146 #define LWIP_HTTPD_MAX_TAG_NAME_LEN 8 00147 #endif 00148 00149 /* The maximum length of string that can be returned to replace any given tag 00150 * If this buffer is not long enough, use LWIP_HTTPD_SSI_MULTIPART. 00151 */ 00152 #if !defined LWIP_HTTPD_MAX_TAG_INSERT_LEN || defined __DOXYGEN__ 00153 #define LWIP_HTTPD_MAX_TAG_INSERT_LEN 192 00154 #endif 00155 00156 #if !defined LWIP_HTTPD_POST_MANUAL_WND || defined __DOXYGEN__ 00157 #define LWIP_HTTPD_POST_MANUAL_WND 0 00158 #endif 00159 00160 /** This string is passed in the HTTP header as "Server: " */ 00161 #if !defined HTTPD_SERVER_AGENT || defined __DOXYGEN__ 00162 #define HTTPD_SERVER_AGENT "lwIP/" LWIP_VERSION_STRING " (http://savannah.nongnu.org/projects/lwip)" 00163 #endif 00164 00165 /** Set this to 1 if you want to include code that creates HTTP headers 00166 * at runtime. Default is off: HTTP headers are then created statically 00167 * by the makefsdata tool. Static headers mean smaller code size, but 00168 * the (readonly) fsdata will grow a bit as every file includes the HTTP 00169 * header. */ 00170 #if !defined LWIP_HTTPD_DYNAMIC_HEADERS || defined __DOXYGEN__ 00171 #define LWIP_HTTPD_DYNAMIC_HEADERS 0 00172 #endif 00173 00174 #if !defined HTTPD_DEBUG || defined __DOXYGEN__ 00175 #define HTTPD_DEBUG LWIP_DBG_OFF 00176 #endif 00177 00178 /** Set this to 1 to use a memp pool for allocating 00179 * struct http_state instead of the heap. 00180 * If enabled, you'll need to define MEMP_NUM_PARALLEL_HTTPD_CONNS 00181 * (and MEMP_NUM_PARALLEL_HTTPD_SSI_CONNS for SSI) to set the size of 00182 * the pool(s). 00183 */ 00184 #if !defined HTTPD_USE_MEM_POOL || defined __DOXYGEN__ 00185 #define HTTPD_USE_MEM_POOL 0 00186 #endif 00187 00188 /** The server port for HTTPD to use */ 00189 #if !defined HTTPD_SERVER_PORT || defined __DOXYGEN__ 00190 #define HTTPD_SERVER_PORT LWIP_IANA_PORT_HTTP 00191 #endif 00192 00193 /** The https server port for HTTPD to use */ 00194 #if !defined HTTPD_SERVER_PORT_HTTPS || defined __DOXYGEN__ 00195 #define HTTPD_SERVER_PORT_HTTPS LWIP_IANA_PORT_HTTPS 00196 #endif 00197 00198 /** Enable https support? */ 00199 #if !defined HTTPD_ENABLE_HTTPS || defined __DOXYGEN__ 00200 #define HTTPD_ENABLE_HTTPS 0 00201 #endif 00202 00203 /** Maximum retries before the connection is aborted/closed. 00204 * - number of times pcb->poll is called -> default is 4*500ms = 2s; 00205 * - reset when pcb->sent is called 00206 */ 00207 #if !defined HTTPD_MAX_RETRIES || defined __DOXYGEN__ 00208 #define HTTPD_MAX_RETRIES 4 00209 #endif 00210 00211 /** The poll delay is X*500ms */ 00212 #if !defined HTTPD_POLL_INTERVAL || defined __DOXYGEN__ 00213 #define HTTPD_POLL_INTERVAL 4 00214 #endif 00215 00216 /** Priority for tcp pcbs created by HTTPD (very low by default). 00217 * Lower priorities get killed first when running out of memory. 00218 */ 00219 #if !defined HTTPD_TCP_PRIO || defined __DOXYGEN__ 00220 #define HTTPD_TCP_PRIO TCP_PRIO_MIN 00221 #endif 00222 00223 /** Set this to 1 to enable timing each file sent */ 00224 #if !defined LWIP_HTTPD_TIMING || defined __DOXYGEN__ 00225 #define LWIP_HTTPD_TIMING 0 00226 #endif 00227 /** Set this to 1 to enable timing each file sent */ 00228 #if !defined HTTPD_DEBUG_TIMING || defined __DOXYGEN__ 00229 #define HTTPD_DEBUG_TIMING LWIP_DBG_OFF 00230 #endif 00231 00232 /** Set this to one to show error pages when parsing a request fails instead 00233 of simply closing the connection. */ 00234 #if !defined LWIP_HTTPD_SUPPORT_EXTSTATUS || defined __DOXYGEN__ 00235 #define LWIP_HTTPD_SUPPORT_EXTSTATUS 0 00236 #endif 00237 00238 /** Set this to 0 to drop support for HTTP/0.9 clients (to save some bytes) */ 00239 #if !defined LWIP_HTTPD_SUPPORT_V09 || defined __DOXYGEN__ 00240 #define LWIP_HTTPD_SUPPORT_V09 1 00241 #endif 00242 00243 /** Set this to 1 to enable HTTP/1.1 persistent connections. 00244 * ATTENTION: If the generated file system includes HTTP headers, these must 00245 * include the "Connection: keep-alive" header (pass argument "-11" to makefsdata). 00246 */ 00247 #if !defined LWIP_HTTPD_SUPPORT_11_KEEPALIVE || defined __DOXYGEN__ 00248 #define LWIP_HTTPD_SUPPORT_11_KEEPALIVE 0 00249 #endif 00250 00251 /** Set this to 1 to support HTTP request coming in in multiple packets/pbufs */ 00252 #if !defined LWIP_HTTPD_SUPPORT_REQUESTLIST || defined __DOXYGEN__ 00253 #define LWIP_HTTPD_SUPPORT_REQUESTLIST 1 00254 #endif 00255 00256 #if LWIP_HTTPD_SUPPORT_REQUESTLIST 00257 /** Number of rx pbufs to enqueue to parse an incoming request (up to the first 00258 newline) */ 00259 #if !defined LWIP_HTTPD_REQ_QUEUELEN || defined __DOXYGEN__ 00260 #define LWIP_HTTPD_REQ_QUEUELEN 5 00261 #endif 00262 00263 /** Number of (TCP payload-) bytes (in pbufs) to enqueue to parse and incoming 00264 request (up to the first double-newline) */ 00265 #if !defined LWIP_HTTPD_REQ_BUFSIZE || defined __DOXYGEN__ 00266 #define LWIP_HTTPD_REQ_BUFSIZE LWIP_HTTPD_MAX_REQ_LENGTH 00267 #endif 00268 00269 /** Defines the maximum length of a HTTP request line (up to the first CRLF, 00270 copied from pbuf into this a global buffer when pbuf- or packet-queues 00271 are received - otherwise the input pbuf is used directly) */ 00272 #if !defined LWIP_HTTPD_MAX_REQ_LENGTH || defined __DOXYGEN__ 00273 #define LWIP_HTTPD_MAX_REQ_LENGTH LWIP_MIN(1023, (LWIP_HTTPD_REQ_QUEUELEN * PBUF_POOL_BUFSIZE)) 00274 #endif 00275 #endif /* LWIP_HTTPD_SUPPORT_REQUESTLIST */ 00276 00277 /** This is the size of a static buffer used when URIs end with '/'. 00278 * In this buffer, the directory requested is concatenated with all the 00279 * configured default file names. 00280 * Set to 0 to disable checking default filenames on non-root directories. 00281 */ 00282 #if !defined LWIP_HTTPD_MAX_REQUEST_URI_LEN || defined __DOXYGEN__ 00283 #define LWIP_HTTPD_MAX_REQUEST_URI_LEN 63 00284 #endif 00285 00286 /** Maximum length of the filename to send as response to a POST request, 00287 * filled in by the application when a POST is finished. 00288 */ 00289 #if !defined LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN || defined __DOXYGEN__ 00290 #define LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN 63 00291 #endif 00292 00293 /** Set this to 0 to not send the SSI tag (default is on, so the tag will 00294 * be sent in the HTML page */ 00295 #if !defined LWIP_HTTPD_SSI_INCLUDE_TAG || defined __DOXYGEN__ 00296 #define LWIP_HTTPD_SSI_INCLUDE_TAG 1 00297 #endif 00298 00299 /** Set this to 1 to call tcp_abort when tcp_close fails with memory error. 00300 * This can be used to prevent consuming all memory in situations where the 00301 * HTTP server has low priority compared to other communication. */ 00302 #if !defined LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR || defined __DOXYGEN__ 00303 #define LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR 0 00304 #endif 00305 00306 /** Set this to 1 to kill the oldest connection when running out of 00307 * memory for 'struct http_state' or 'struct http_ssi_state'. 00308 * ATTENTION: This puts all connections on a linked list, so may be kind of slow. 00309 */ 00310 #if !defined LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED || defined __DOXYGEN__ 00311 #define LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED 0 00312 #endif 00313 00314 /** Set this to 1 to send URIs without extension without headers 00315 * (who uses this at all??) */ 00316 #if !defined LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI || defined __DOXYGEN__ 00317 #define LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI 0 00318 #endif 00319 00320 /** Default: Tags are sent from struct http_state and are therefore volatile */ 00321 #if !defined HTTP_IS_TAG_VOLATILE || defined __DOXYGEN__ 00322 #define HTTP_IS_TAG_VOLATILE(ptr) TCP_WRITE_FLAG_COPY 00323 #endif 00324 00325 /* By default, the httpd is limited to send 2*pcb->mss to keep resource usage low 00326 when http is not an important protocol in the device. */ 00327 #if !defined HTTPD_LIMIT_SENDING_TO_2MSS || defined __DOXYGEN__ 00328 #define HTTPD_LIMIT_SENDING_TO_2MSS 1 00329 #endif 00330 00331 /* Define this to a function that returns the maximum amount of data to enqueue. 00332 The function have this signature: u16_t fn(struct altcp_pcb* pcb); 00333 The best place to define this is the hooks file (@see LWIP_HOOK_FILENAME) */ 00334 #if !defined HTTPD_MAX_WRITE_LEN || defined __DOXYGEN__ 00335 #if HTTPD_LIMIT_SENDING_TO_2MSS 00336 #define HTTPD_MAX_WRITE_LEN(pcb) ((u16_t)(2 * altcp_mss(pcb))) 00337 #endif 00338 #endif 00339 00340 /*------------------- FS OPTIONS -------------------*/ 00341 00342 /** Set this to 1 and provide the functions: 00343 * - "int fs_open_custom(struct fs_file *file, const char *name)" 00344 * Called first for every opened file to allow opening files 00345 * that are not included in fsdata(_custom).c 00346 * - "void fs_close_custom(struct fs_file *file)" 00347 * Called to free resources allocated by fs_open_custom(). 00348 */ 00349 #if !defined LWIP_HTTPD_CUSTOM_FILES || defined __DOXYGEN__ 00350 #define LWIP_HTTPD_CUSTOM_FILES 0 00351 #endif 00352 00353 /** Set this to 1 to support fs_read() to dynamically read file data. 00354 * Without this (default=off), only one-block files are supported, 00355 * and the contents must be ready after fs_open(). 00356 */ 00357 #if !defined LWIP_HTTPD_DYNAMIC_FILE_READ || defined __DOXYGEN__ 00358 #define LWIP_HTTPD_DYNAMIC_FILE_READ 0 00359 #endif 00360 00361 /** Set this to 1 to include an application state argument per file 00362 * that is opened. This allows to keep a state per connection/file. 00363 */ 00364 #if !defined LWIP_HTTPD_FILE_STATE || defined __DOXYGEN__ 00365 #define LWIP_HTTPD_FILE_STATE 0 00366 #endif 00367 00368 /** HTTPD_PRECALCULATED_CHECKSUM==1: include precompiled checksums for 00369 * predefined (MSS-sized) chunks of the files to prevent having to calculate 00370 * the checksums at runtime. */ 00371 #if !defined HTTPD_PRECALCULATED_CHECKSUM || defined __DOXYGEN__ 00372 #define HTTPD_PRECALCULATED_CHECKSUM 0 00373 #endif 00374 00375 /** LWIP_HTTPD_FS_ASYNC_READ==1: support asynchronous read operations 00376 * (fs_read_async returns FS_READ_DELAYED and calls a callback when finished). 00377 */ 00378 #if !defined LWIP_HTTPD_FS_ASYNC_READ || defined __DOXYGEN__ 00379 #define LWIP_HTTPD_FS_ASYNC_READ 0 00380 #endif 00381 00382 /** Filename (including path) to use as FS data file */ 00383 #if !defined HTTPD_FSDATA_FILE || defined __DOXYGEN__ 00384 /* HTTPD_USE_CUSTOM_FSDATA: Compatibility with deprecated lwIP option */ 00385 #if defined(HTTPD_USE_CUSTOM_FSDATA) && (HTTPD_USE_CUSTOM_FSDATA != 0) 00386 #define HTTPD_FSDATA_FILE "fsdata_custom.c" 00387 #else 00388 #define HTTPD_FSDATA_FILE "fsdata.c" 00389 #endif 00390 #endif 00391 00392 /** 00393 * @} 00394 */ 00395 00396 #endif /* LWIP_HDR_APPS_HTTPD_OPTS_H */
Generated on Tue Jul 12 2022 13:54:24 by
1.7.2