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: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
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 00046 /** 00047 * @defgroup httpd_opts Options 00048 * @ingroup httpd 00049 * @{ 00050 */ 00051 00052 /** Set this to 1 to support CGI (old style) */ 00053 #if !defined LWIP_HTTPD_CGI || defined __DOXYGEN__ 00054 #define LWIP_HTTPD_CGI 0 00055 #endif 00056 00057 /** Set this to 1 to support CGI (new style) */ 00058 #if !defined LWIP_HTTPD_CGI_SSI || defined __DOXYGEN__ 00059 #define LWIP_HTTPD_CGI_SSI 0 00060 #endif 00061 00062 /** Set this to 1 to support SSI (Server-Side-Includes) */ 00063 #if !defined LWIP_HTTPD_SSI || defined __DOXYGEN__ 00064 #define LWIP_HTTPD_SSI 0 00065 #endif 00066 00067 /** Set this to 1 to implement an SSI tag handler callback that gets a const char* 00068 * to the tag (instead of an index into a pre-registered array of known tags) */ 00069 #if !defined LWIP_HTTPD_SSI_RAW || defined __DOXYGEN__ 00070 #define LWIP_HTTPD_SSI_RAW 0 00071 #endif 00072 00073 /** Set this to 1 to support HTTP POST */ 00074 #if !defined LWIP_HTTPD_SUPPORT_POST || defined __DOXYGEN__ 00075 #define LWIP_HTTPD_SUPPORT_POST 0 00076 #endif 00077 00078 /* The maximum number of parameters that the CGI handler can be sent. */ 00079 #if !defined LWIP_HTTPD_MAX_CGI_PARAMETERS || defined __DOXYGEN__ 00080 #define LWIP_HTTPD_MAX_CGI_PARAMETERS 16 00081 #endif 00082 00083 /** LWIP_HTTPD_SSI_MULTIPART==1: SSI handler function is called with 2 more 00084 * arguments indicating a counter for insert string that are too long to be 00085 * inserted at once: the SSI handler function must then set 'next_tag_part' 00086 * which will be passed back to it in the next call. */ 00087 #if !defined LWIP_HTTPD_SSI_MULTIPART || defined __DOXYGEN__ 00088 #define LWIP_HTTPD_SSI_MULTIPART 0 00089 #endif 00090 00091 /* The maximum length of the string comprising the tag name */ 00092 #if !defined LWIP_HTTPD_MAX_TAG_NAME_LEN || defined __DOXYGEN__ 00093 #define LWIP_HTTPD_MAX_TAG_NAME_LEN 8 00094 #endif 00095 00096 /* The maximum length of string that can be returned to replace any given tag */ 00097 #if !defined LWIP_HTTPD_MAX_TAG_INSERT_LEN || defined __DOXYGEN__ 00098 #define LWIP_HTTPD_MAX_TAG_INSERT_LEN 192 00099 #endif 00100 00101 #if !defined LWIP_HTTPD_POST_MANUAL_WND || defined __DOXYGEN__ 00102 #define LWIP_HTTPD_POST_MANUAL_WND 0 00103 #endif 00104 00105 /** This string is passed in the HTTP header as "Server: " */ 00106 #if !defined HTTPD_SERVER_AGENT || defined __DOXYGEN__ 00107 #define HTTPD_SERVER_AGENT "lwIP/" LWIP_VERSION_STRING " (http://savannah.nongnu.org/projects/lwip)" 00108 #endif 00109 00110 /** Set this to 1 if you want to include code that creates HTTP headers 00111 * at runtime. Default is off: HTTP headers are then created statically 00112 * by the makefsdata tool. Static headers mean smaller code size, but 00113 * the (readonly) fsdata will grow a bit as every file includes the HTTP 00114 * header. */ 00115 #if !defined LWIP_HTTPD_DYNAMIC_HEADERS || defined __DOXYGEN__ 00116 #define LWIP_HTTPD_DYNAMIC_HEADERS 0 00117 #endif 00118 00119 #if !defined HTTPD_DEBUG || defined __DOXYGEN__ 00120 #define HTTPD_DEBUG LWIP_DBG_OFF 00121 #endif 00122 00123 /** Set this to 1 to use a memp pool for allocating 00124 * struct http_state instead of the heap. 00125 */ 00126 #if !defined HTTPD_USE_MEM_POOL || defined __DOXYGEN__ 00127 #define HTTPD_USE_MEM_POOL 0 00128 #endif 00129 00130 /** The server port for HTTPD to use */ 00131 #if !defined HTTPD_SERVER_PORT || defined __DOXYGEN__ 00132 #define HTTPD_SERVER_PORT 80 00133 #endif 00134 00135 /** Maximum retries before the connection is aborted/closed. 00136 * - number of times pcb->poll is called -> default is 4*500ms = 2s; 00137 * - reset when pcb->sent is called 00138 */ 00139 #if !defined HTTPD_MAX_RETRIES || defined __DOXYGEN__ 00140 #define HTTPD_MAX_RETRIES 4 00141 #endif 00142 00143 /** The poll delay is X*500ms */ 00144 #if !defined HTTPD_POLL_INTERVAL || defined __DOXYGEN__ 00145 #define HTTPD_POLL_INTERVAL 4 00146 #endif 00147 00148 /** Priority for tcp pcbs created by HTTPD (very low by default). 00149 * Lower priorities get killed first when running out of memory. 00150 */ 00151 #if !defined HTTPD_TCP_PRIO || defined __DOXYGEN__ 00152 #define HTTPD_TCP_PRIO TCP_PRIO_MIN 00153 #endif 00154 00155 /** Set this to 1 to enable timing each file sent */ 00156 #if !defined LWIP_HTTPD_TIMING || defined __DOXYGEN__ 00157 #define LWIP_HTTPD_TIMING 0 00158 #endif 00159 /** Set this to 1 to enable timing each file sent */ 00160 #if !defined HTTPD_DEBUG_TIMING || defined __DOXYGEN__ 00161 #define HTTPD_DEBUG_TIMING LWIP_DBG_OFF 00162 #endif 00163 00164 /** Set this to 1 on platforms where strnstr is not available */ 00165 #if !defined LWIP_HTTPD_STRNSTR_PRIVATE || defined __DOXYGEN__ 00166 #define LWIP_HTTPD_STRNSTR_PRIVATE 1 00167 #endif 00168 00169 /** Set this to 1 on platforms where stricmp is not available */ 00170 #if !defined LWIP_HTTPD_STRICMP_PRIVATE || defined __DOXYGEN__ 00171 #define LWIP_HTTPD_STRICMP_PRIVATE 0 00172 #endif 00173 00174 /** Define this to a smaller function if you have itoa() at hand... */ 00175 #if !defined LWIP_HTTPD_ITOA || defined __DOXYGEN__ 00176 #if !defined LWIP_HTTPD_ITOA_PRIVATE || defined __DOXYGEN__ 00177 #define LWIP_HTTPD_ITOA_PRIVATE 1 00178 #endif 00179 #if LWIP_HTTPD_ITOA_PRIVATE 00180 #define LWIP_HTTPD_ITOA(buffer, bufsize, number) httpd_itoa(number, buffer) 00181 #else 00182 #define LWIP_HTTPD_ITOA(buffer, bufsize, number) snprintf(buffer, bufsize, "%d", number) 00183 #endif 00184 #endif 00185 00186 /** Set this to one to show error pages when parsing a request fails instead 00187 of simply closing the connection. */ 00188 #if !defined LWIP_HTTPD_SUPPORT_EXTSTATUS || defined __DOXYGEN__ 00189 #define LWIP_HTTPD_SUPPORT_EXTSTATUS 0 00190 #endif 00191 00192 /** Set this to 0 to drop support for HTTP/0.9 clients (to save some bytes) */ 00193 #if !defined LWIP_HTTPD_SUPPORT_V09 || defined __DOXYGEN__ 00194 #define LWIP_HTTPD_SUPPORT_V09 1 00195 #endif 00196 00197 /** Set this to 1 to enable HTTP/1.1 persistent connections. 00198 * ATTENTION: If the generated file system includes HTTP headers, these must 00199 * include the "Connection: keep-alive" header (pass argument "-11" to makefsdata). 00200 */ 00201 #if !defined LWIP_HTTPD_SUPPORT_11_KEEPALIVE || defined __DOXYGEN__ 00202 #define LWIP_HTTPD_SUPPORT_11_KEEPALIVE 0 00203 #endif 00204 00205 /** Set this to 1 to support HTTP request coming in in multiple packets/pbufs */ 00206 #if !defined LWIP_HTTPD_SUPPORT_REQUESTLIST || defined __DOXYGEN__ 00207 #define LWIP_HTTPD_SUPPORT_REQUESTLIST 1 00208 #endif 00209 00210 #if LWIP_HTTPD_SUPPORT_REQUESTLIST 00211 /** Number of rx pbufs to enqueue to parse an incoming request (up to the first 00212 newline) */ 00213 #if !defined LWIP_HTTPD_REQ_QUEUELEN || defined __DOXYGEN__ 00214 #define LWIP_HTTPD_REQ_QUEUELEN 5 00215 #endif 00216 00217 /** Number of (TCP payload-) bytes (in pbufs) to enqueue to parse and incoming 00218 request (up to the first double-newline) */ 00219 #if !defined LWIP_HTTPD_REQ_BUFSIZE || defined __DOXYGEN__ 00220 #define LWIP_HTTPD_REQ_BUFSIZE LWIP_HTTPD_MAX_REQ_LENGTH 00221 #endif 00222 00223 /** Defines the maximum length of a HTTP request line (up to the first CRLF, 00224 copied from pbuf into this a global buffer when pbuf- or packet-queues 00225 are received - otherwise the input pbuf is used directly) */ 00226 #if !defined LWIP_HTTPD_MAX_REQ_LENGTH || defined __DOXYGEN__ 00227 #define LWIP_HTTPD_MAX_REQ_LENGTH LWIP_MIN(1023, (LWIP_HTTPD_REQ_QUEUELEN * PBUF_POOL_BUFSIZE)) 00228 #endif 00229 #endif /* LWIP_HTTPD_SUPPORT_REQUESTLIST */ 00230 00231 /** This is the size of a static buffer used when URIs end with '/'. 00232 * In this buffer, the directory requested is concatenated with all the 00233 * configured default file names. 00234 * Set to 0 to disable checking default filenames on non-root directories. 00235 */ 00236 #if !defined LWIP_HTTPD_MAX_REQUEST_URI_LEN || defined __DOXYGEN__ 00237 #define LWIP_HTTPD_MAX_REQUEST_URI_LEN 63 00238 #endif 00239 00240 /** Maximum length of the filename to send as response to a POST request, 00241 * filled in by the application when a POST is finished. 00242 */ 00243 #if !defined LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN || defined __DOXYGEN__ 00244 #define LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN 63 00245 #endif 00246 00247 /** Set this to 0 to not send the SSI tag (default is on, so the tag will 00248 * be sent in the HTML page */ 00249 #if !defined LWIP_HTTPD_SSI_INCLUDE_TAG || defined __DOXYGEN__ 00250 #define LWIP_HTTPD_SSI_INCLUDE_TAG 1 00251 #endif 00252 00253 /** Set this to 1 to call tcp_abort when tcp_close fails with memory error. 00254 * This can be used to prevent consuming all memory in situations where the 00255 * HTTP server has low priority compared to other communication. */ 00256 #if !defined LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR || defined __DOXYGEN__ 00257 #define LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR 0 00258 #endif 00259 00260 /** Set this to 1 to kill the oldest connection when running out of 00261 * memory for 'struct http_state' or 'struct http_ssi_state'. 00262 * ATTENTION: This puts all connections on a linked list, so may be kind of slow. 00263 */ 00264 #if !defined LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED || defined __DOXYGEN__ 00265 #define LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED 0 00266 #endif 00267 00268 /** Set this to 1 to send URIs without extension without headers 00269 * (who uses this at all??) */ 00270 #if !defined LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI || defined __DOXYGEN__ 00271 #define LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI 0 00272 #endif 00273 00274 /** Default: Tags are sent from struct http_state and are therefore volatile */ 00275 #if !defined HTTP_IS_TAG_VOLATILE || defined __DOXYGEN__ 00276 #define HTTP_IS_TAG_VOLATILE(ptr) TCP_WRITE_FLAG_COPY 00277 #endif 00278 00279 /* By default, the httpd is limited to send 2*pcb->mss to keep resource usage low 00280 when http is not an important protocol in the device. */ 00281 #if !defined HTTPD_LIMIT_SENDING_TO_2MSS || defined __DOXYGEN__ 00282 #define HTTPD_LIMIT_SENDING_TO_2MSS 1 00283 #endif 00284 00285 /* Define this to a function that returns the maximum amount of data to enqueue. 00286 The function have this signature: u16_t fn(struct tcp_pcb* pcb); */ 00287 #if !defined HTTPD_MAX_WRITE_LEN || defined __DOXYGEN__ 00288 #if HTTPD_LIMIT_SENDING_TO_2MSS 00289 #define HTTPD_MAX_WRITE_LEN(pcb) (2 * tcp_mss(pcb)) 00290 #endif 00291 #endif 00292 00293 /*------------------- FS OPTIONS -------------------*/ 00294 00295 /** Set this to 1 and provide the functions: 00296 * - "int fs_open_custom(struct fs_file *file, const char *name)" 00297 * Called first for every opened file to allow opening files 00298 * that are not included in fsdata(_custom).c 00299 * - "void fs_close_custom(struct fs_file *file)" 00300 * Called to free resources allocated by fs_open_custom(). 00301 */ 00302 #if !defined LWIP_HTTPD_CUSTOM_FILES || defined __DOXYGEN__ 00303 #define LWIP_HTTPD_CUSTOM_FILES 0 00304 #endif 00305 00306 /** Set this to 1 to support fs_read() to dynamically read file data. 00307 * Without this (default=off), only one-block files are supported, 00308 * and the contents must be ready after fs_open(). 00309 */ 00310 #if !defined LWIP_HTTPD_DYNAMIC_FILE_READ || defined __DOXYGEN__ 00311 #define LWIP_HTTPD_DYNAMIC_FILE_READ 0 00312 #endif 00313 00314 /** Set this to 1 to include an application state argument per file 00315 * that is opened. This allows to keep a state per connection/file. 00316 */ 00317 #if !defined LWIP_HTTPD_FILE_STATE || defined __DOXYGEN__ 00318 #define LWIP_HTTPD_FILE_STATE 0 00319 #endif 00320 00321 /** HTTPD_PRECALCULATED_CHECKSUM==1: include precompiled checksums for 00322 * predefined (MSS-sized) chunks of the files to prevent having to calculate 00323 * the checksums at runtime. */ 00324 #if !defined HTTPD_PRECALCULATED_CHECKSUM || defined __DOXYGEN__ 00325 #define HTTPD_PRECALCULATED_CHECKSUM 0 00326 #endif 00327 00328 /** LWIP_HTTPD_FS_ASYNC_READ==1: support asynchronous read operations 00329 * (fs_read_async returns FS_READ_DELAYED and calls a callback when finished). 00330 */ 00331 #if !defined LWIP_HTTPD_FS_ASYNC_READ || defined __DOXYGEN__ 00332 #define LWIP_HTTPD_FS_ASYNC_READ 0 00333 #endif 00334 00335 /** Set this to 1 to include "fsdata_custom.c" instead of "fsdata.c" for the 00336 * file system (to prevent changing the file included in CVS) */ 00337 #if !defined HTTPD_USE_CUSTOM_FSDATA || defined __DOXYGEN__ 00338 #define HTTPD_USE_CUSTOM_FSDATA 0 00339 #endif 00340 00341 /** 00342 * @} 00343 */ 00344 00345 #endif /* LWIP_HDR_APPS_HTTPD_OPTS_H */
Generated on Tue Jul 12 2022 11:02:39 by
