|
|
|
|
@ -43,34 +43,40 @@
|
|
|
|
|
|
|
|
|
|
#include "lwip/opt.h" |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @defgroup httpd_opts Options |
|
|
|
|
* @ingroup httpd |
|
|
|
|
* @{ |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/** Set this to 1 to support CGI (old style) */ |
|
|
|
|
#ifndef LWIP_HTTPD_CGI |
|
|
|
|
#if !defined LWIP_HTTPD_CGI || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_CGI 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 1 to support CGI (new style) */ |
|
|
|
|
#ifndef LWIP_HTTPD_CGI_SSI |
|
|
|
|
#if !defined LWIP_HTTPD_CGI_SSI || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_CGI_SSI 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 1 to support SSI (Server-Side-Includes) */ |
|
|
|
|
#ifndef LWIP_HTTPD_SSI |
|
|
|
|
#if !defined LWIP_HTTPD_SSI || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_SSI 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 1 to implement an SSI tag handler callback that gets a const char*
|
|
|
|
|
* to the tag (instead of an index into a pre-registered array of known tags) */ |
|
|
|
|
#ifndef LWIP_HTTPD_SSI_RAW |
|
|
|
|
#if !defined LWIP_HTTPD_SSI_RAW || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_SSI_RAW 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 1 to support HTTP POST */ |
|
|
|
|
#ifndef LWIP_HTTPD_SUPPORT_POST |
|
|
|
|
#if !defined LWIP_HTTPD_SUPPORT_POST || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_SUPPORT_POST 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/* The maximum number of parameters that the CGI handler can be sent. */ |
|
|
|
|
#ifndef LWIP_HTTPD_MAX_CGI_PARAMETERS |
|
|
|
|
#if !defined LWIP_HTTPD_MAX_CGI_PARAMETERS || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_MAX_CGI_PARAMETERS 16 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
@ -78,26 +84,26 @@
|
|
|
|
|
* arguments indicating a counter for insert string that are too long to be |
|
|
|
|
* inserted at once: the SSI handler function must then set 'next_tag_part' |
|
|
|
|
* which will be passed back to it in the next call. */ |
|
|
|
|
#ifndef LWIP_HTTPD_SSI_MULTIPART |
|
|
|
|
#if !defined LWIP_HTTPD_SSI_MULTIPART || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_SSI_MULTIPART 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/* The maximum length of the string comprising the tag name */ |
|
|
|
|
#ifndef LWIP_HTTPD_MAX_TAG_NAME_LEN |
|
|
|
|
#if !defined LWIP_HTTPD_MAX_TAG_NAME_LEN || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_MAX_TAG_NAME_LEN 8 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/* The maximum length of string that can be returned to replace any given tag */ |
|
|
|
|
#ifndef LWIP_HTTPD_MAX_TAG_INSERT_LEN |
|
|
|
|
#if !defined LWIP_HTTPD_MAX_TAG_INSERT_LEN || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_MAX_TAG_INSERT_LEN 192 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#ifndef LWIP_HTTPD_POST_MANUAL_WND |
|
|
|
|
#if !defined LWIP_HTTPD_POST_MANUAL_WND || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_POST_MANUAL_WND 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** This string is passed in the HTTP header as "Server: " */ |
|
|
|
|
#ifndef HTTPD_SERVER_AGENT |
|
|
|
|
#if !defined HTTPD_SERVER_AGENT || defined __DOXYGEN__ |
|
|
|
|
#define HTTPD_SERVER_AGENT "lwIP/" LWIP_VERSION_STRING " (http://savannah.nongnu.org/projects/lwip)"
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
@ -106,23 +112,23 @@
|
|
|
|
|
* by the makefsdata tool. Static headers mean smaller code size, but |
|
|
|
|
* the (readonly) fsdata will grow a bit as every file includes the HTTP |
|
|
|
|
* header. */ |
|
|
|
|
#ifndef LWIP_HTTPD_DYNAMIC_HEADERS |
|
|
|
|
#if !defined LWIP_HTTPD_DYNAMIC_HEADERS || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_DYNAMIC_HEADERS 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#ifndef HTTPD_DEBUG |
|
|
|
|
#if !defined HTTPD_DEBUG || defined __DOXYGEN__ |
|
|
|
|
#define HTTPD_DEBUG LWIP_DBG_OFF |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 1 to use a memp pool for allocating
|
|
|
|
|
* struct http_state instead of the heap. |
|
|
|
|
*/ |
|
|
|
|
#ifndef HTTPD_USE_MEM_POOL |
|
|
|
|
#if !defined HTTPD_USE_MEM_POOL || defined __DOXYGEN__ |
|
|
|
|
#define HTTPD_USE_MEM_POOL 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** The server port for HTTPD to use */ |
|
|
|
|
#ifndef HTTPD_SERVER_PORT |
|
|
|
|
#if !defined HTTPD_SERVER_PORT || defined __DOXYGEN__ |
|
|
|
|
#define HTTPD_SERVER_PORT 80 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
@ -130,43 +136,44 @@
|
|
|
|
|
* - number of times pcb->poll is called -> default is 4*500ms = 2s; |
|
|
|
|
* - reset when pcb->sent is called |
|
|
|
|
*/ |
|
|
|
|
#ifndef HTTPD_MAX_RETRIES |
|
|
|
|
#if !defined HTTPD_MAX_RETRIES || defined __DOXYGEN__ |
|
|
|
|
#define HTTPD_MAX_RETRIES 4 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** The poll delay is X*500ms */ |
|
|
|
|
#ifndef HTTPD_POLL_INTERVAL |
|
|
|
|
#if !defined HTTPD_POLL_INTERVAL || defined __DOXYGEN__ |
|
|
|
|
#define HTTPD_POLL_INTERVAL 4 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Priority for tcp pcbs created by HTTPD (very low by default).
|
|
|
|
|
* Lower priorities get killed first when running out of memory. |
|
|
|
|
*/ |
|
|
|
|
#ifndef HTTPD_TCP_PRIO |
|
|
|
|
#if !defined HTTPD_TCP_PRIO || defined __DOXYGEN__ |
|
|
|
|
#define HTTPD_TCP_PRIO TCP_PRIO_MIN |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 1 to enable timing each file sent */ |
|
|
|
|
#ifndef LWIP_HTTPD_TIMING |
|
|
|
|
#if !defined LWIP_HTTPD_TIMING || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_TIMING 0 |
|
|
|
|
#endif |
|
|
|
|
#ifndef HTTPD_DEBUG_TIMING |
|
|
|
|
/** Set this to 1 to enable timing each file sent */ |
|
|
|
|
#if !defined HTTPD_DEBUG_TIMING || defined __DOXYGEN__ |
|
|
|
|
#define HTTPD_DEBUG_TIMING LWIP_DBG_OFF |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 1 on platforms where strnstr is not available */ |
|
|
|
|
#ifndef LWIP_HTTPD_STRNSTR_PRIVATE |
|
|
|
|
#if !defined LWIP_HTTPD_STRNSTR_PRIVATE || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_STRNSTR_PRIVATE 1 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 1 on platforms where stricmp is not available */ |
|
|
|
|
#ifndef LWIP_HTTPD_STRICMP_PRIVATE |
|
|
|
|
#if !defined LWIP_HTTPD_STRICMP_PRIVATE || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_STRICMP_PRIVATE 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Define this to a smaller function if you have itoa() at hand... */ |
|
|
|
|
#ifndef LWIP_HTTPD_ITOA |
|
|
|
|
#ifndef LWIP_HTTPD_ITOA_PRIVATE |
|
|
|
|
#if !defined LWIP_HTTPD_ITOA || defined __DOXYGEN__ |
|
|
|
|
#if !defined LWIP_HTTPD_ITOA_PRIVATE || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_ITOA_PRIVATE 1 |
|
|
|
|
#endif |
|
|
|
|
#if LWIP_HTTPD_ITOA_PRIVATE |
|
|
|
|
@ -178,12 +185,12 @@
|
|
|
|
|
|
|
|
|
|
/** Set this to one to show error pages when parsing a request fails instead
|
|
|
|
|
of simply closing the connection. */ |
|
|
|
|
#ifndef LWIP_HTTPD_SUPPORT_EXTSTATUS |
|
|
|
|
#if !defined LWIP_HTTPD_SUPPORT_EXTSTATUS || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_SUPPORT_EXTSTATUS 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 0 to drop support for HTTP/0.9 clients (to save some bytes) */ |
|
|
|
|
#ifndef LWIP_HTTPD_SUPPORT_V09 |
|
|
|
|
#if !defined LWIP_HTTPD_SUPPORT_V09 || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_SUPPORT_V09 1 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
@ -191,32 +198,32 @@
|
|
|
|
|
* ATTENTION: If the generated file system includes HTTP headers, these must |
|
|
|
|
* include the "Connection: keep-alive" header (pass argument "-11" to makefsdata). |
|
|
|
|
*/ |
|
|
|
|
#ifndef LWIP_HTTPD_SUPPORT_11_KEEPALIVE |
|
|
|
|
#if !defined LWIP_HTTPD_SUPPORT_11_KEEPALIVE || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_SUPPORT_11_KEEPALIVE 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 1 to support HTTP request coming in in multiple packets/pbufs */ |
|
|
|
|
#ifndef LWIP_HTTPD_SUPPORT_REQUESTLIST |
|
|
|
|
#if !defined LWIP_HTTPD_SUPPORT_REQUESTLIST || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_SUPPORT_REQUESTLIST 1 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#if LWIP_HTTPD_SUPPORT_REQUESTLIST |
|
|
|
|
/** Number of rx pbufs to enqueue to parse an incoming request (up to the first
|
|
|
|
|
newline) */ |
|
|
|
|
#ifndef LWIP_HTTPD_REQ_QUEUELEN |
|
|
|
|
#if !defined LWIP_HTTPD_REQ_QUEUELEN || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_REQ_QUEUELEN 5 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Number of (TCP payload-) bytes (in pbufs) to enqueue to parse and incoming
|
|
|
|
|
request (up to the first double-newline) */ |
|
|
|
|
#ifndef LWIP_HTTPD_REQ_BUFSIZE |
|
|
|
|
#if !defined LWIP_HTTPD_REQ_BUFSIZE || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_REQ_BUFSIZE LWIP_HTTPD_MAX_REQ_LENGTH |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Defines the maximum length of a HTTP request line (up to the first CRLF,
|
|
|
|
|
copied from pbuf into this a global buffer when pbuf- or packet-queues |
|
|
|
|
are received - otherwise the input pbuf is used directly) */ |
|
|
|
|
#ifndef LWIP_HTTPD_MAX_REQ_LENGTH |
|
|
|
|
#if !defined LWIP_HTTPD_MAX_REQ_LENGTH || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_MAX_REQ_LENGTH LWIP_MIN(1023, (LWIP_HTTPD_REQ_QUEUELEN * PBUF_POOL_BUFSIZE)) |
|
|
|
|
#endif |
|
|
|
|
#endif /* LWIP_HTTPD_SUPPORT_REQUESTLIST */ |
|
|
|
|
@ -226,27 +233,27 @@
|
|
|
|
|
* configured default file names. |
|
|
|
|
* Set to 0 to disable checking default filenames on non-root directories. |
|
|
|
|
*/ |
|
|
|
|
#ifndef LWIP_HTTPD_MAX_REQUEST_URI_LEN |
|
|
|
|
#if !defined LWIP_HTTPD_MAX_REQUEST_URI_LEN || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_MAX_REQUEST_URI_LEN 63 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Maximum length of the filename to send as response to a POST request,
|
|
|
|
|
* filled in by the application when a POST is finished. |
|
|
|
|
*/ |
|
|
|
|
#ifndef LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN |
|
|
|
|
#if !defined LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN 63 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 0 to not send the SSI tag (default is on, so the tag will
|
|
|
|
|
* be sent in the HTML page */ |
|
|
|
|
#ifndef LWIP_HTTPD_SSI_INCLUDE_TAG |
|
|
|
|
#if !defined LWIP_HTTPD_SSI_INCLUDE_TAG || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_SSI_INCLUDE_TAG 1 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 1 to call tcp_abort when tcp_close fails with memory error.
|
|
|
|
|
* This can be used to prevent consuming all memory in situations where the |
|
|
|
|
* HTTP server has low priority compared to other communication. */ |
|
|
|
|
#ifndef LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR |
|
|
|
|
#if !defined LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
@ -254,30 +261,30 @@
|
|
|
|
|
* memory for 'struct http_state' or 'struct http_ssi_state'. |
|
|
|
|
* ATTENTION: This puts all connections on a linked list, so may be kind of slow. |
|
|
|
|
*/ |
|
|
|
|
#ifndef LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED |
|
|
|
|
#if !defined LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 1 to send URIs without extension without headers
|
|
|
|
|
* (who uses this at all??) */ |
|
|
|
|
#ifndef LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI |
|
|
|
|
#if !defined LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Default: Tags are sent from struct http_state and are therefore volatile */ |
|
|
|
|
#ifndef HTTP_IS_TAG_VOLATILE |
|
|
|
|
#if !defined HTTP_IS_TAG_VOLATILE || defined __DOXYGEN__ |
|
|
|
|
#define HTTP_IS_TAG_VOLATILE(ptr) TCP_WRITE_FLAG_COPY |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/* By default, the httpd is limited to send 2*pcb->mss to keep resource usage low
|
|
|
|
|
when http is not an important protocol in the device. */ |
|
|
|
|
#ifndef HTTPD_LIMIT_SENDING_TO_2MSS |
|
|
|
|
#if !defined HTTPD_LIMIT_SENDING_TO_2MSS || defined __DOXYGEN__ |
|
|
|
|
#define HTTPD_LIMIT_SENDING_TO_2MSS 1 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/* Define this to a function that returns the maximum amount of data to enqueue.
|
|
|
|
|
The function have this signature: u16_t fn(struct tcp_pcb* pcb); */ |
|
|
|
|
#ifndef HTTPD_MAX_WRITE_LEN |
|
|
|
|
#if !defined HTTPD_MAX_WRITE_LEN || defined __DOXYGEN__ |
|
|
|
|
#if HTTPD_LIMIT_SENDING_TO_2MSS |
|
|
|
|
#define HTTPD_MAX_WRITE_LEN(pcb) (2 * tcp_mss(pcb)) |
|
|
|
|
#endif |
|
|
|
|
@ -292,7 +299,7 @@
|
|
|
|
|
* - "void fs_close_custom(struct fs_file *file)" |
|
|
|
|
* Called to free resources allocated by fs_open_custom(). |
|
|
|
|
*/ |
|
|
|
|
#ifndef LWIP_HTTPD_CUSTOM_FILES |
|
|
|
|
#if !defined LWIP_HTTPD_CUSTOM_FILES || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_CUSTOM_FILES 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
@ -300,35 +307,39 @@
|
|
|
|
|
* Without this (default=off), only one-block files are supported, |
|
|
|
|
* and the contents must be ready after fs_open(). |
|
|
|
|
*/ |
|
|
|
|
#ifndef LWIP_HTTPD_DYNAMIC_FILE_READ |
|
|
|
|
#if !defined LWIP_HTTPD_DYNAMIC_FILE_READ || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_DYNAMIC_FILE_READ 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 1 to include an application state argument per file
|
|
|
|
|
* that is opened. This allows to keep a state per connection/file. |
|
|
|
|
*/ |
|
|
|
|
#ifndef LWIP_HTTPD_FILE_STATE |
|
|
|
|
#if !defined LWIP_HTTPD_FILE_STATE || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_FILE_STATE 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** HTTPD_PRECALCULATED_CHECKSUM==1: include precompiled checksums for
|
|
|
|
|
* predefined (MSS-sized) chunks of the files to prevent having to calculate |
|
|
|
|
* the checksums at runtime. */ |
|
|
|
|
#ifndef HTTPD_PRECALCULATED_CHECKSUM |
|
|
|
|
#if !defined HTTPD_PRECALCULATED_CHECKSUM || defined __DOXYGEN__ |
|
|
|
|
#define HTTPD_PRECALCULATED_CHECKSUM 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** LWIP_HTTPD_FS_ASYNC_READ==1: support asynchronous read operations
|
|
|
|
|
* (fs_read_async returns FS_READ_DELAYED and calls a callback when finished). |
|
|
|
|
*/ |
|
|
|
|
#ifndef LWIP_HTTPD_FS_ASYNC_READ |
|
|
|
|
#if !defined LWIP_HTTPD_FS_ASYNC_READ || defined __DOXYGEN__ |
|
|
|
|
#define LWIP_HTTPD_FS_ASYNC_READ 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Set this to 1 to include "fsdata_custom.c" instead of "fsdata.c" for the
|
|
|
|
|
* file system (to prevent changing the file included in CVS) */ |
|
|
|
|
#ifndef HTTPD_USE_CUSTOM_FSDATA |
|
|
|
|
#if !defined HTTPD_USE_CUSTOM_FSDATA || defined __DOXYGEN__ |
|
|
|
|
#define HTTPD_USE_CUSTOM_FSDATA 0 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#endif /* LWIP_HDR_APPS_HTTPD_OPTS_H */ |
|
|
|
|
/**
|
|
|
|
|
* @} |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#endif /* LWIP_HDR_APPS_HTTPD_OPTS_H */ |
|
|
|
|
|