[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 05/07: response headers: do not add automatic "Content-L
From: |
gnunet |
Subject: |
[libmicrohttpd] 05/07: response headers: do not add automatic "Content-Length" header if response already has it |
Date: |
Mon, 07 Mar 2022 19:36:12 +0100 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 406c434c722668687d7d752c8d2b6054d4340f3d
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Mon Mar 7 21:08:53 2022 +0300
response headers: do not add automatic "Content-Length" header if response
already has it
If application used MHD_RF_INSANITY_HEADER_CONTENT_LENGTH response flag
and added manual "Content-Length" header, MHD will not add the correct
header.
---
src/microhttpd/connection.c | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index f408d1f1..88b1f21d 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2175,6 +2175,7 @@ build_header_response (struct MHD_Connection *connection)
if (c->rp_props.use_reply_body_headers)
{
/* Body-specific headers */
+
if (c->rp_props.chunked)
{ /* Chunked encoding is used */
if (0 == (r->flags_auto & MHD_RAF_HAS_TRANS_ENC_CHUNKED))
@@ -2185,23 +2186,26 @@ build_header_response (struct MHD_Connection
*connection)
return MHD_NO;
}
}
- else
- { /* Chunked encoding is not used */
+ else /* Chunked encoding is not used */
+ {
if (MHD_SIZE_UNKNOWN != r->total_size)
- {
- if (! buffer_append_s (buf, &pos, buf_size,
- MHD_HTTP_HEADER_CONTENT_LENGTH ": "))
- return MHD_NO;
- el_size = MHD_uint64_to_str (r->total_size, buf + pos,
- buf_size - pos);
- if (0 == el_size)
- return MHD_NO;
- pos += el_size;
-
- if (buf_size < pos + 2)
- return MHD_NO;
- buf[pos++] = '\r';
- buf[pos++] = '\n';
+ { /* The size is known */
+ if (0 == (r->flags_auto & MHD_RAF_HAS_CONTENT_LENGTH))
+ { /* The response does not have "Content-Length" header */
+ if (! buffer_append_s (buf, &pos, buf_size,
+ MHD_HTTP_HEADER_CONTENT_LENGTH ": "))
+ return MHD_NO;
+ el_size = MHD_uint64_to_str (r->total_size, buf + pos,
+ buf_size - pos);
+ if (0 == el_size)
+ return MHD_NO;
+ pos += el_size;
+
+ if (buf_size < pos + 2)
+ return MHD_NO;
+ buf[pos++] = '\r';
+ buf[pos++] = '\n';
+ }
}
}
}
--
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, 2022/03/07
- [libmicrohttpd] 05/07: response headers: do not add automatic "Content-Length" header if response already has it,
gnunet <=
- [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