[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 03/07: response: added automatic flag MHD_RAF_HAS_CONTEN
From: |
gnunet |
Subject: |
[libmicrohttpd] 03/07: response: added automatic flag MHD_RAF_HAS_CONTENT_LENGTH |
Date: |
Mon, 07 Mar 2022 19:36:10 +0100 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit aa69e178d21cb3dcfd8bd11e56cc6dc6ae39adb6
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Mar 6 21:11:26 2022 +0300
response: added automatic flag MHD_RAF_HAS_CONTENT_LENGTH
---
src/microhttpd/internal.h | 5 +++--
src/microhttpd/response.c | 36 ++++++++++++++++++++++++++++++------
2 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 277510d8..2cfe6455 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -327,8 +327,9 @@ enum MHD_ResponseAutoFlags
MHD_RAF_NO_FLAGS = 0, /**< No auto flags */
MHD_RAF_HAS_CONNECTION_HDR = 1 << 0, /**< Has "Connection" header */
MHD_RAF_HAS_CONNECTION_CLOSE = 1 << 1, /**< Has "Connection: close" */
- MHD_RAF_HAS_TRANS_ENC_CHUNKED = 1 << 2, /**< Has "Transfer-Encoding: chunked
*/
- MHD_RAF_HAS_DATE_HDR = 1 << 3 /**< Has "Date" header */
+ MHD_RAF_HAS_TRANS_ENC_CHUNKED = 1 << 2, /**< Has "Transfer-Encoding:
chunked" */
+ MHD_RAF_HAS_CONTENT_LENGTH = 1 << 3, /**< Has "Content-Length" header */
+ MHD_RAF_HAS_DATE_HDR = 1 << 4 /**< Has "Date" header */
} _MHD_FIXED_FLAGS_ENUM;
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index ca3639f4..6ea7a753 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -541,13 +541,24 @@ MHD_add_response_header (struct MHD_Response *response,
}
return MHD_NO;
}
- if ( (0 == (MHD_RF_INSANITY_HEADER_CONTENT_LENGTH
- & response->flags)) &&
- (MHD_str_equal_caseless_ (header,
- MHD_HTTP_HEADER_CONTENT_LENGTH)) )
+
+ if (MHD_str_equal_caseless_ (header,
+ MHD_HTTP_HEADER_CONTENT_LENGTH))
{
- /* MHD will set Content-length if allowed and possible,
- reject attempt by application */
+ if (0 == (MHD_RF_INSANITY_HEADER_CONTENT_LENGTH & response->flags))
+ {
+ /* MHD sets automatically correct Content-Length always when needed,
+ reject attempt to manually override it */
+ return MHD_NO;
+ }
+ if (MHD_NO != add_response_entry (response,
+ MHD_HEADER_KIND,
+ header,
+ content))
+ {
+ response->flags_auto |= MHD_RAF_HAS_CONTENT_LENGTH;
+ return MHD_YES;
+ }
return MHD_NO;
}
@@ -644,6 +655,19 @@ MHD_del_response_header (struct MHD_Response *response,
header_len) )
response->flags_auto &=
~((enum MHD_ResponseAutoFlags) MHD_RAF_HAS_DATE_HDR);
+ else if ( (MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH) ==
+ header_len) &&
+ MHD_str_equal_caseless_bin_n_ (header,
+ MHD_HTTP_HEADER_CONTENT_LENGTH,
+ header_len) )
+ {
+ if (NULL == MHD_get_response_element_n_ (response,
+ MHD_HEADER_KIND,
+
MHD_HTTP_HEADER_CONTENT_LENGTH,
+ header_len))
+ response->flags_auto &=
+ ~((enum MHD_ResponseAutoFlags) MHD_RAF_HAS_CONTENT_LENGTH);
+ }
return MHD_YES;
}
pos = pos->next;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (02634d01 -> 1a46bfd6), gnunet, 2022/03/07
- [libmicrohttpd] 01/07: connection.c: added function to check used reply, gnunet, 2022/03/07
- [libmicrohttpd] 07/07: memorypool: fixed: unpoison memory for ASAN before destroying pool, gnunet, 2022/03/07
- [libmicrohttpd] 04/07: response.c: fixed coding style, gnunet, 2022/03/07
- [libmicrohttpd] 03/07: response: added automatic flag MHD_RAF_HAS_CONTENT_LENGTH,
gnunet <=
- [libmicrohttpd] 05/07: response headers: do not add automatic "Content-Length" header if response already has it, gnunet, 2022/03/07
- [libmicrohttpd] 06/07: reply: warn if manual "Content-Length" is used when this header is not allowed, gnunet, 2022/03/07
- [libmicrohttpd] 02/07: MHD_queue_response(): improved doxy, gnunet, 2022/03/07