aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-05-15 21:02:48 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-05-15 21:02:48 +0300
commit7899565cef80da2787920ed267a01060b45bdb43 (patch)
treef045472ec0544453bad4328ec769c6204189d6eb
parentd08fb47c0a53a658fdd97fd1a4e265aade576418 (diff)
downloadlibmicrohttpd-7899565cef80da2787920ed267a01060b45bdb43.tar.gz
libmicrohttpd-7899565cef80da2787920ed267a01060b45bdb43.zip
Made cookie parsing optional feature
-rw-r--r--configure.ac15
-rw-r--r--src/include/microhttpd.h13
-rw-r--r--src/microhttpd/connection.c7
-rw-r--r--src/microhttpd/daemon.c6
-rw-r--r--src/testcurl/Makefile.am8
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"]],
2879AM_CONDITIONAL([ENABLE_UPGRADE], [[test "x$enable_httpupgrade" = "xyes"]]) 2879AM_CONDITIONAL([ENABLE_UPGRADE], [[test "x$enable_httpupgrade" = "xyes"]])
2880AC_MSG_RESULT([[$enable_httpupgrade]]) 2880AC_MSG_RESULT([[$enable_httpupgrade]])
2881 2881
2882# optional: HTTP cookie parsing support. Enabled by default
2883AC_MSG_CHECKING([[whether to support HTTP cookie parsing]])
2884AC_ARG_ENABLE([[cookie]],
2885 AS_HELP_STRING([[--disable-cookie]],
2886 [disable HTTP cookie parsing support]),
2887 [AS_VAR_IF([[enable_cookie]],[["no"]],[],[[enable_cookie='yes']])],
2888 [[enable_cookie='yes']])
2889AS_VAR_IF([[enable_cookie]],[["yes"]],
2890 [
2891 AC_DEFINE([[COOKIE_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTP cookie parsing support.]) ])
2892AM_CONDITIONAL([ENABLE_COOKIE], [[test "x$enable_cookie" = "xyes"]])
2893AC_MSG_RESULT([[$enable_cookie]])
2894
2882AC_CACHE_CHECK([[for calloc()]], [[mhd_cv_have_func_calloc]], 2895AC_CACHE_CHECK([[for calloc()]], [[mhd_cv_have_func_calloc]],
2883 [ 2896 [
2884 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 2897 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@@ -3749,6 +3762,7 @@ AC_MSG_NOTICE([GNU libmicrohttpd ${PACKAGE_VERSION} Configuration Summary:
3749 Basic auth.: ${enable_bauth} 3762 Basic auth.: ${enable_bauth}
3750 Digest auth.: ${enable_dauth} 3763 Digest auth.: ${enable_dauth}
3751 HTTP "Upgrade": ${enable_httpupgrade} 3764 HTTP "Upgrade": ${enable_httpupgrade}
3765 Cookie parsing: ${enable_cookie}
3752 Postproc: ${enable_postprocessor} 3766 Postproc: ${enable_postprocessor}
3753 Build docs: ${enable_doc} 3767 Build docs: ${enable_doc}
3754 Build examples: ${enable_examples} 3768 Build examples: ${enable_examples}
@@ -3766,5 +3780,6 @@ AS_IF([test "x$enable_https" = "xyes"],
3766AS_IF([test "x$enable_bauth" != "xyes" || \ 3780AS_IF([test "x$enable_bauth" != "xyes" || \
3767 test "x$enable_dauth" != "xyes" || \ 3781 test "x$enable_dauth" != "xyes" || \
3768 test "x$enable_httpupgrade" != "xyes" || \ 3782 test "x$enable_httpupgrade" != "xyes" || \
3783 test "x$enable_cookie" != "xyes" || \
3769 test "x$enable_postprocessor" != "xyes"], 3784 test "x$enable_postprocessor" != "xyes"],
3770 [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.])]) 3785 [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"
96 * they are parsed as decimal numbers. 96 * they are parsed as decimal numbers.
97 * Example: 0x01093001 = 1.9.30-1. 97 * Example: 0x01093001 = 1.9.30-1.
98 */ 98 */
99#define MHD_VERSION 0x00097513 99#define MHD_VERSION 0x00097514
100 100
101/* If generic headers don't work on your platform, include headers 101/* If generic headers don't work on your platform, include headers
102 which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', 'off_t', 102 which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', 'off_t',
@@ -4964,7 +4964,16 @@ enum MHD_FEATURE
4964 * Get whether option #MHD_OPTION_HTTPS_CERT_CALLBACK2 is 4964 * Get whether option #MHD_OPTION_HTTPS_CERT_CALLBACK2 is
4965 * supported. 4965 * supported.
4966 */ 4966 */
4967 MHD_FEATURE_HTTPS_CERT_CALLBACK2 = 23 4967 MHD_FEATURE_HTTPS_CERT_CALLBACK2 = 23,
4968
4969 /**
4970 * Get whether option automatic parsing of HTTP Cookie header
4971 * is enabled.
4972 * If disabled, no MHD_COOKIE_KIND will be generated by MHD.
4973 * MHD versions before 0x00097514 always support cookie parsing.
4974 * @note Available since #MHD_VERSION 0x00097514
4975 */
4976 MHD_FEATURE_HTTPS_COOKIE_PARSING = 24
4968} _MHD_FIXED_ENUM; 4977} _MHD_FIXED_ENUM;
4969 4978
4970 4979
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,
2752} 2752}
2753 2753
2754 2754
2755#ifdef COOKIE_SUPPORT
2756
2755/** 2757/**
2756 * Cookie parsing result 2758 * Cookie parsing result
2757 */ 2759 */
@@ -3111,6 +3113,8 @@ parse_cookie_header (struct MHD_Connection *connection)
3111} 3113}
3112 3114
3113 3115
3116#endif /* COOKIE_SUPPORT */
3117
3114/** 3118/**
3115 * Detect HTTP version 3119 * Detect HTTP version
3116 * 3120 *
@@ -3850,6 +3854,8 @@ parse_connection_headers (struct MHD_Connection *connection)
3850 const char *clen; 3854 const char *clen;
3851 const char *enc; 3855 const char *enc;
3852 size_t val_len; 3856 size_t val_len;
3857
3858#ifdef COOKIE_SUPPORT
3853 enum _MHD_ParseCookie cookie_res; 3859 enum _MHD_ParseCookie cookie_res;
3854 3860
3855 cookie_res = parse_cookie_header (connection); 3861 cookie_res = parse_cookie_header (connection);
@@ -3881,6 +3887,7 @@ parse_connection_headers (struct MHD_Connection *connection)
3881#endif 3887#endif
3882 (void) 0; /* Mute compiler warning */ 3888 (void) 0; /* Mute compiler warning */
3883 } 3889 }
3890#endif /* COOKIE_SUPPORT */
3884 if ( (1 <= connection->daemon->strict_for_client) && 3891 if ( (1 <= connection->daemon->strict_for_client) &&
3885 (MHD_IS_HTTP_VER_1_1_COMPAT (connection->http_ver)) && 3892 (MHD_IS_HTTP_VER_1_1_COMPAT (connection->http_ver)) &&
3886 (MHD_NO == 3893 (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)
8289#else 8289#else
8290 return MHD_NO; 8290 return MHD_NO;
8291#endif 8291#endif
8292 case MHD_FEATURE_HTTPS_COOKIE_PARSING:
8293#if defined(COOKIE_SUPPORT)
8294 return MHD_YES;
8295#else
8296 return MHD_NO;
8297#endif
8292 8298
8293 } 8299 }
8294 return MHD_NO; 8300 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 = \
102 test_add_conn_nolisten \ 102 test_add_conn_nolisten \
103 test_process_headers \ 103 test_process_headers \
104 test_process_arguments \ 104 test_process_arguments \
105 test_parse_cookies \
106 test_parse_cookies_invalid \
107 test_toolarge_method \ 105 test_toolarge_method \
108 test_toolarge_url \ 106 test_toolarge_url \
109 test_toolarge_request_header_name \ 107 test_toolarge_request_header_name \
@@ -142,6 +140,12 @@ check_PROGRAMS = \
142 test_callback \ 140 test_callback \
143 $(EMPTY_ITEM) 141 $(EMPTY_ITEM)
144 142
143if ENABLE_COOKIE
144check_PROGRAMS += \
145 test_parse_cookies \
146 test_parse_cookies_invalid
147endif
148
145if HEAVY_TESTS 149if HEAVY_TESTS
146check_PROGRAMS += \ 150check_PROGRAMS += \
147 perf_get 151 perf_get