mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-21 23:56:59 +08:00
httpd improvements: added persistent connections, improved asynchronous read mode, compile-time deflate compression, new CGI mode, SSI handler can be called with tag string (instead of tag index)
This commit is contained in:
@@ -50,6 +50,9 @@ struct fsdata_chksum {
|
||||
};
|
||||
#endif /* HTTPD_PRECALCULATED_CHECKSUM */
|
||||
|
||||
#define FS_FILE_FLAGS_HEADER_INCLUDED 0x01
|
||||
#define FS_FILE_FLAGS_HEADER_PERSISTENT 0x02
|
||||
|
||||
struct fs_file {
|
||||
const char *data;
|
||||
int len;
|
||||
@@ -59,7 +62,7 @@ struct fs_file {
|
||||
const struct fsdata_chksum *chksum;
|
||||
u16_t chksum_count;
|
||||
#endif /* HTTPD_PRECALCULATED_CHECKSUM */
|
||||
u8_t http_header_included;
|
||||
u8_t flags;
|
||||
#if LWIP_HTTPD_CUSTOM_FILES
|
||||
u8_t is_custom_file;
|
||||
#endif /* LWIP_HTTPD_CUSTOM_FILES */
|
||||
|
||||
@@ -92,6 +92,27 @@ void http_set_cgi_handlers(const tCGI *pCGIs, int iNumHandlers);
|
||||
|
||||
#endif /* LWIP_HTTPD_CGI */
|
||||
|
||||
#if LWIP_HTTPD_CGI || LWIP_HTTPD_CGI_SSI
|
||||
|
||||
/* The maximum number of parameters that the CGI handler can be sent. */
|
||||
#ifndef LWIP_HTTPD_MAX_CGI_PARAMETERS
|
||||
#define LWIP_HTTPD_MAX_CGI_PARAMETERS 16
|
||||
#endif
|
||||
|
||||
#if LWIP_HTTPD_CGI_SSI
|
||||
/** Define this generic CGI handler in your application.
|
||||
* It is called once for every URI with parameters.
|
||||
* The parameters can be stored to
|
||||
*/
|
||||
extern void httpd_cgi_handler(const char* uri, int iNumParams, char **pcParam, char **pcValue
|
||||
#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE
|
||||
, void *connection_state
|
||||
#endif /* LWIP_HTTPD_FILE_STATE */
|
||||
);
|
||||
#endif /* LWIP_HTTPD_CGI_SSI */
|
||||
|
||||
#endif /* LWIP_HTTPD_CGI || LWIP_HTTPD_CGI_SSI */
|
||||
|
||||
#if LWIP_HTTPD_SSI
|
||||
|
||||
/*
|
||||
@@ -123,7 +144,13 @@ void http_set_cgi_handlers(const tCGI *pCGIs, int iNumHandlers);
|
||||
* output JavaScript code must do so in an encapsulated way, sending the whole
|
||||
* HTML <script>...</script> section as a single include.
|
||||
*/
|
||||
typedef u16_t (*tSSIHandler)(int iIndex, char *pcInsert, int iInsertLen
|
||||
typedef u16_t (*tSSIHandler)(
|
||||
#if LWIP_HTTPD_SSI_RAW
|
||||
const char* ssi_tag_name,
|
||||
#else /* LWIP_HTTPD_SSI_RAW */
|
||||
int iIndex,
|
||||
#endif /* LWIP_HTTPD_SSI_RAW */
|
||||
char *pcInsert, int iInsertLen
|
||||
#if LWIP_HTTPD_SSI_MULTIPART
|
||||
, u16_t current_tag_part, u16_t *next_tag_part
|
||||
#endif /* LWIP_HTTPD_SSI_MULTIPART */
|
||||
@@ -132,9 +159,18 @@ typedef u16_t (*tSSIHandler)(int iIndex, char *pcInsert, int iInsertLen
|
||||
#endif /* LWIP_HTTPD_FILE_STATE */
|
||||
);
|
||||
|
||||
/** Set the SSI handler function
|
||||
* (if LWIP_HTTPD_SSI_RAW==1, only the first argument is used)
|
||||
*/
|
||||
void http_set_ssi_handler(tSSIHandler pfnSSIHandler,
|
||||
const char **ppcTags, int iNumTags);
|
||||
|
||||
/** For LWIP_HTTPD_SSI_RAW==1, return this to indicat the tag is unknown.
|
||||
* In this case, the webserver writes a warning into the page.
|
||||
* You can also just return 0 to write nothing for unknown tags.
|
||||
*/
|
||||
#define HTTPD_SSI_TAG_UNKNOWN 0xFFFF
|
||||
|
||||
#endif /* LWIP_HTTPD_SSI */
|
||||
|
||||
#if LWIP_HTTPD_SUPPORT_POST
|
||||
@@ -192,8 +228,9 @@ void httpd_post_data_recved(void *connection, u16_t recved_len);
|
||||
|
||||
void httpd_init(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_APPS_HTTPD_H */
|
||||
#endif /* LWIP_HTTPD_H */
|
||||
|
||||
@@ -38,11 +38,16 @@
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/** Set this to 1 to support CGI */
|
||||
/** Set this to 1 to support CGI (old style) */
|
||||
#ifndef LWIP_HTTPD_CGI
|
||||
#define LWIP_HTTPD_CGI 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to support CGI (new style) */
|
||||
#ifndef LWIP_HTTPD_CGI_SSI
|
||||
#define LWIP_HTTPD_CGI_SSI 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to support SSI (Server-Side-Includes) */
|
||||
#ifndef LWIP_HTTPD_SSI
|
||||
#define LWIP_HTTPD_SSI 0
|
||||
@@ -143,6 +148,28 @@
|
||||
#define LWIP_HTTPD_STRNSTR_PRIVATE 1
|
||||
#endif
|
||||
|
||||
/** Set this to 1 on platforms where stricmp is not available */
|
||||
#ifndef LWIP_HTTPD_STRICMP_PRIVATE
|
||||
#define LWIP_HTTPD_STRICMP_PRIVATE 0
|
||||
#endif
|
||||
|
||||
/** Set this to 1 on platforms where stricmp is not available */
|
||||
#ifndef LWIP_HTTPD_ITOA_PRIVATE
|
||||
#define LWIP_HTTPD_ITOA_PRIVATE 1
|
||||
#endif
|
||||
|
||||
/** Define this to a smaller function if you have itoa() at hand... */
|
||||
#ifndef LWIP_HTTPD_ITOA
|
||||
#ifndef LWIP_HTTPD_ITOA_PRIVATE
|
||||
#define LWIP_HTTPD_ITOA_PRIVATE 1
|
||||
#endif
|
||||
#if LWIP_HTTPD_ITOA_PRIVATE
|
||||
#define LWIP_HTTPD_ITOA(buffer, bufsize, number) httpd_itoa(number, buffer)
|
||||
#else
|
||||
#define LWIP_HTTPD_ITOA(buffer, bufsize, number) snprintf(buffer, bufsize, "%d", number)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** Set this to one to show error pages when parsing a request fails instead
|
||||
of simply closing the connection. */
|
||||
#ifndef LWIP_HTTPD_SUPPORT_EXTSTATUS
|
||||
@@ -188,6 +215,15 @@
|
||||
#endif
|
||||
#endif /* LWIP_HTTPD_SUPPORT_REQUESTLIST */
|
||||
|
||||
/** This is the size of a static buffer used when URIs end with '/'.
|
||||
* In this buffer, the directory requested is concatenated with all the
|
||||
* configured default file names.
|
||||
* Set to 0 to disable checking default filenames on non-root directories.
|
||||
*/
|
||||
#ifndef LWIP_HTTPD_MAX_REQUEST_URI_LEN
|
||||
#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.
|
||||
*/
|
||||
@@ -216,6 +252,12 @@
|
||||
#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
|
||||
#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
|
||||
#define HTTP_IS_TAG_VOLATILE(ptr) TCP_WRITE_FLAG_COPY
|
||||
|
||||
Reference in New Issue
Block a user