libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

commit a098c2d3a391381a506f0055b5909bc5e50aaeb2
parent ea79eedaaf2145a759b93255b7c0354bafc4625a
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 30 May 2026 23:54:26 +0200

initialze has_hdr_date and has_hdr_conn properly

Diffstat:
Msrc/include/microhttpd2.h | 10++++++++++
Msrc/include/microhttpd2_preamble.h.in | 10++++++++++
Msrc/mhd2/mhd_response.h | 4++--
Msrc/mhd2/mhd_str.h | 2+-
Msrc/mhd2/response_add_header.c | 17++++++++++++++++-
5 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/src/include/microhttpd2.h b/src/include/microhttpd2.h @@ -1330,6 +1330,16 @@ enum MHD_FIXED_ENUM_MHD_SET_ MHD_StatusCode MHD_SC_REPLY_NONCE_ERROR = 50233 , /** + * MHD refused to add duplicate DATE header. + */ + MHD_SC_DATE_HEADER_SEVERAL = 50234 + , + /** + * MHD refused to add duplicate CONNECTION header. + */ + MHD_SC_CONNECTION_HEADER_SEVERAL = 50345 + , + /** * Failed to allocate memory in connection's pool for the reply. */ MHD_SC_ERR_RESPONSE_ALLOCATION_FAILURE = 50250 diff --git a/src/include/microhttpd2_preamble.h.in b/src/include/microhttpd2_preamble.h.in @@ -1330,6 +1330,16 @@ enum MHD_FIXED_ENUM_MHD_SET_ MHD_StatusCode MHD_SC_REPLY_NONCE_ERROR = 50233 , /** + * MHD refused to add duplicate DATE header. + */ + MHD_SC_DATE_HEADER_SEVERAL = 50234 + , + /** + * MHD refused to add duplicate CONNECTION header. + */ + MHD_SC_CONNECTION_HEADER_SEVERAL = 50345 + , + /** * Failed to allocate memory in connection's pool for the reply. */ MHD_SC_ERR_RESPONSE_ALLOCATION_FAILURE = 50250 diff --git a/src/mhd2/mhd_response.h b/src/mhd2/mhd_response.h @@ -285,12 +285,12 @@ struct mhd_ResponseConfiguration /** * Response has "Date:" header */ - bool has_hdr_date; // TODO: set the member + bool has_hdr_date; /** * Response has "Connection:" header */ - bool has_hdr_conn; // TODO: set the member + bool has_hdr_conn; /** * Response is internal-only error response diff --git a/src/mhd2/mhd_str.h b/src/mhd2/mhd_str.h @@ -135,7 +135,7 @@ MHD_FN_PURE_ MHD_FN_PAR_NONNULL_ALL_ MHD_FN_PAR_IN_ (1) MHD_FN_PAR_IN_ (2); * Comparison stops at first unmatched byte. * @param arr the statically allocated string to compare * @param str the string to compare - * @param l the number of characters in the @a s string + * @param l the number of characters in the @a str string * @return 'true' if two strings are equal, 'false' otherwise. */ #define mhd_str_equal_caseless_n_st(arr,str,l) \ diff --git a/src/mhd2/response_add_header.c b/src/mhd2/response_add_header.c @@ -293,7 +293,22 @@ MHD_response_add_header (struct MHD_Response *MHD_RESTRICT response, else need_unlock = false; - // TODO: add special processing for "Date", "Connection", "Content-Length", "Transfer-Encoding" + if (mhd_str_equal_caseless (MHD_HTTP_HEADER_DATE, + name)) + { + if (response->cfg.has_hdr_date) + return MHD_SC_DATE_HEADER_SEVERAL; + response->cfg.has_hdr_date = true; + } + if (mhd_str_equal_caseless (MHD_HTTP_HEADER_CONNECTION, + name)) + { + if (response->cfg.has_hdr_conn) + return MHD_SC_CONNECTION_HEADER_SEVERAL; + response->cfg.has_hdr_conn = true; + } + + // TODO: add special processing for "Content-Length", "Transfer-Encoding" res = response_add_header_int (response, name, value);