Made cookie parsing optional feature

This commit is contained in:
Evgeny Grin (Karlson2k)
2022-05-15 21:02:48 +03:00
parent d08fb47c0a
commit 7899565cef
5 changed files with 45 additions and 4 deletions
+15
View File
@@ -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.])])
+11 -2
View File
@@ -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;
+7
View File
@@ -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 ==
+6
View File
@@ -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;
+6 -2
View File
@@ -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