From ff8d1a384f2e4e5284e265ee8cdb1a9b566445b7 Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Tue, 23 Oct 2018 08:17:45 +0200 Subject: [PATCH] httpd: SSI types should be overridable (task #15071) Add define LWIP_HTTPD_SSI_EXTENSIONS to make the extension list overridable, clarify documentation of LWIP_HTTPD_SSI_BY_FILE_EXTENSION a bit. Signed-off-by: Simon Goldschmidt --- src/apps/http/httpd_structs.h | 6 +++--- src/include/lwip/apps/httpd_opts.h | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/apps/http/httpd_structs.h b/src/apps/http/httpd_structs.h index 56b97a32..aa5bce2f 100644 --- a/src/apps/http/httpd_structs.h +++ b/src/apps/http/httpd_structs.h @@ -113,11 +113,11 @@ static const tHTTPHeader g_psHTTPHeaders[] = { #endif /* LWIP_HTTPD_DYNAMIC_HEADERS */ -#if LWIP_HTTPD_SSI +#if LWIP_HTTPD_SSI && LWIP_HTTPD_SSI_BY_FILE_EXTENSION static const char *const g_pcSSIExtensions[] = { - ".shtml", ".shtm", ".ssi", ".xml", ".json" + LWIP_HTTPD_SSI_EXTENSIONS }; #define NUM_SHTML_EXTENSIONS LWIP_ARRAYSIZE(g_pcSSIExtensions) -#endif /* LWIP_HTTPD_SSI */ +#endif /* LWIP_HTTPD_SSI && LWIP_HTTPD_SSI_BY_FILE_EXTENSION */ #endif /* LWIP_HTTPD_STRUCTS_H */ diff --git a/src/include/lwip/apps/httpd_opts.h b/src/include/lwip/apps/httpd_opts.h index dd0c075d..573eb86c 100644 --- a/src/include/lwip/apps/httpd_opts.h +++ b/src/include/lwip/apps/httpd_opts.h @@ -112,7 +112,9 @@ /** Set this to 0 to prevent parsing the file extension at runtime to decide * if a file should be scanned for SSI tags or not. * Default is 1 (file extensions are checked using the g_pcSSIExtensions array) - * Set to 2 to override this runtime test function. + * Set to 2 to override this runtime test function. In this case, you have to + * provide an external function that does the check: + * u8_t http_uri_is_ssi(struct fs_file *file, const char *uri) * * This is enabled by default, but if you only use a newer version of makefsdata * supporting the "-ssi" option, this info is already present in @@ -121,6 +123,14 @@ #define LWIP_HTTPD_SSI_BY_FILE_EXTENSION 1 #endif +/** This is a list of file extensions handled as SSI files. This define + * is used to initialize a 'const char *const[]'. It is only used if + * LWIP_HTTPD_SSI_BY_FILE_EXTENSION != 0. + */ +#if !defined LWIP_HTTPD_SSI_EXTENSIONS || defined __DOXYGEN__ +#define LWIP_HTTPD_SSI_EXTENSIONS ".shtml", ".shtm", ".ssi", ".xml", ".json" +#endif + /** Set this to 1 to support HTTP POST */ #if !defined LWIP_HTTPD_SUPPORT_POST || defined __DOXYGEN__ #define LWIP_HTTPD_SUPPORT_POST 0