[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 02/02: Made cookie parsing optional feature
From: |
gnunet |
Subject: |
[libmicrohttpd] 02/02: Made cookie parsing optional feature |
Date: |
Sun, 15 May 2022 20:02:58 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 7899565cef80da2787920ed267a01060b45bdb43
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun May 15 21:02:48 2022 +0300
Made cookie parsing optional feature
---
configure.ac | 15 +++++++++++++++
src/include/microhttpd.h | 13 +++++++++++--
src/microhttpd/connection.c | 7 +++++++
src/microhttpd/daemon.c | 6 ++++++
src/testcurl/Makefile.am | 8 ++++++--
5 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index 30041fd8..652f5b10 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2879,6 +2879,19 @@ AS_VAR_IF([[enable_httpupgrade]],[["yes"]],
AM_CONDITIONAL([ENABLE_UPGRADE], [[test "x$enable_httpupgrade" = "xyes"]])
AC_MSG_RESULT([[$enable_httpupgrade]])
+# optional: HTTP cookie parsing support. Enabled by default
+AC_MSG_CHECKING([[whether to support HTTP cookie parsing]])
+AC_ARG_ENABLE([[cookie]],
+ AS_HELP_STRING([[--disable-cookie]],
+ [disable HTTP cookie parsing support]),
+ [AS_VAR_IF([[enable_cookie]],[["no"]],[],[[enable_cookie='yes']])],
+ [[enable_cookie='yes']])
+AS_VAR_IF([[enable_cookie]],[["yes"]],
+ [
+ AC_DEFINE([[COOKIE_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is
compiled with HTTP cookie parsing support.]) ])
+AM_CONDITIONAL([ENABLE_COOKIE], [[test "x$enable_cookie" = "xyes"]])
+AC_MSG_RESULT([[$enable_cookie]])
+
AC_CACHE_CHECK([[for calloc()]], [[mhd_cv_have_func_calloc]],
[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@@ -3749,6 +3762,7 @@ AC_MSG_NOTICE([GNU libmicrohttpd ${PACKAGE_VERSION}
Configuration Summary:
Basic auth.: ${enable_bauth}
Digest auth.: ${enable_dauth}
HTTP "Upgrade": ${enable_httpupgrade}
+ Cookie parsing: ${enable_cookie}
Postproc: ${enable_postprocessor}
Build docs: ${enable_doc}
Build examples: ${enable_examples}
@@ -3766,5 +3780,6 @@ AS_IF([test "x$enable_https" = "xyes"],
AS_IF([test "x$enable_bauth" != "xyes" || \
test "x$enable_dauth" != "xyes" || \
test "x$enable_httpupgrade" != "xyes" || \
+ test "x$enable_cookie" != "xyes" || \
test "x$enable_postprocessor" != "xyes"],
[AC_MSG_NOTICE([WARNING: This will be a custom build with missing symbols.
Do NOT use this build in a distribution. Building with these kinds of configure
options is only for custom builds for embedded systems.])])
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 3e1dbc96..84561dec 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -96,7 +96,7 @@ extern "C"
* they are parsed as decimal numbers.
* Example: 0x01093001 = 1.9.30-1.
*/
-#define MHD_VERSION 0x00097513
+#define MHD_VERSION 0x00097514
/* If generic headers don't work on your platform, include headers
which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', 'off_t',
@@ -4964,7 +4964,16 @@ enum MHD_FEATURE
* Get whether option #MHD_OPTION_HTTPS_CERT_CALLBACK2 is
* supported.
*/
- MHD_FEATURE_HTTPS_CERT_CALLBACK2 = 23
+ MHD_FEATURE_HTTPS_CERT_CALLBACK2 = 23,
+
+ /**
+ * Get whether option automatic parsing of HTTP Cookie header
+ * is enabled.
+ * If disabled, no MHD_COOKIE_KIND will be generated by MHD.
+ * MHD versions before 0x00097514 always support cookie parsing.
+ * @note Available since #MHD_VERSION 0x00097514
+ */
+ MHD_FEATURE_HTTPS_COOKIE_PARSING = 24
} _MHD_FIXED_ENUM;
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 47d63d1f..e563fb71 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2752,6 +2752,8 @@ connection_add_header (struct MHD_Connection *connection,
}
+#ifdef COOKIE_SUPPORT
+
/**
* Cookie parsing result
*/
@@ -3111,6 +3113,8 @@ parse_cookie_header (struct MHD_Connection *connection)
}
+#endif /* COOKIE_SUPPORT */
+
/**
* Detect HTTP version
*
@@ -3850,6 +3854,8 @@ parse_connection_headers (struct MHD_Connection
*connection)
const char *clen;
const char *enc;
size_t val_len;
+
+#ifdef COOKIE_SUPPORT
enum _MHD_ParseCookie cookie_res;
cookie_res = parse_cookie_header (connection);
@@ -3881,6 +3887,7 @@ parse_connection_headers (struct MHD_Connection
*connection)
#endif
(void) 0; /* Mute compiler warning */
}
+#endif /* COOKIE_SUPPORT */
if ( (1 <= connection->daemon->strict_for_client) &&
(MHD_IS_HTTP_VER_1_1_COMPAT (connection->http_ver)) &&
(MHD_NO ==
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index e96ef4a2..b179297b 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -8289,6 +8289,12 @@ MHD_is_feature_supported (enum MHD_FEATURE feature)
#else
return MHD_NO;
#endif
+ case MHD_FEATURE_HTTPS_COOKIE_PARSING:
+#if defined(COOKIE_SUPPORT)
+ return MHD_YES;
+#else
+ return MHD_NO;
+#endif
}
return MHD_NO;
diff --git a/src/testcurl/Makefile.am b/src/testcurl/Makefile.am
index 58158b18..4b0c3d1c 100644
--- a/src/testcurl/Makefile.am
+++ b/src/testcurl/Makefile.am
@@ -102,8 +102,6 @@ check_PROGRAMS = \
test_add_conn_nolisten \
test_process_headers \
test_process_arguments \
- test_parse_cookies \
- test_parse_cookies_invalid \
test_toolarge_method \
test_toolarge_url \
test_toolarge_request_header_name \
@@ -142,6 +140,12 @@ check_PROGRAMS = \
test_callback \
$(EMPTY_ITEM)
+if ENABLE_COOKIE
+check_PROGRAMS += \
+ test_parse_cookies \
+ test_parse_cookies_invalid
+endif
+
if HEAVY_TESTS
check_PROGRAMS += \
perf_get
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.