libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 678dcd0931b9d98b7831f224801aaf54ff9596c2
parent 2cab7e09b796aa3c228b1b5e04844061a9e78812
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Tue, 27 Jul 2021 17:59:38 +0300

response: use auto flag for chunked encoding header

Diffstat:
Msrc/microhttpd/response.c | 26+++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c @@ -468,9 +468,23 @@ MHD_add_response_header (struct MHD_Response *response, "chunked" is not allowed. Note that MHD will set the correct transfer encoding if required automatically. */ /* NOTE: for compressed bodies, use the "Content-encoding" header */ - if ( (! MHD_str_equal_caseless_ (content, "identity")) && - (! MHD_str_equal_caseless_ (content, "chunked")) ) - return MHD_NO; + if (MHD_str_equal_caseless_ (content, "identity")) + return add_response_entry (response, + MHD_HEADER_KIND, + header, + content); + else if (MHD_str_equal_caseless_ (content, "chunked")) + { + if (MHD_NO != add_response_entry (response, + MHD_HEADER_KIND, + header, + content)) + { + response->flags_auto |= MHD_RAF_HAS_TRANS_ENC_CHUNKED; + return MHD_YES; + } + } + return MHD_NO; } if ( (0 == (MHD_RF_INSANITY_HEADER_CONTENT_LENGTH & response->flags)) && @@ -555,6 +569,12 @@ MHD_del_response_header (struct MHD_Response *response, free (pos->header); free (pos->value); free (pos); + if ( (MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_TRANSFER_ENCODING) == + header_len) && + MHD_str_equal_caseless_bin_n_ (header, + MHD_HTTP_HEADER_TRANSFER_ENCODING, + header_len) ) + response->flags_auto &= ~(MHD_RAF_HAS_TRANS_ENC_CHUNKED); return MHD_YES; } pos = pos->next;