libmicrohttpd

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

commit 692e8c56553a4ec0a432704816b8340711b68aed
parent dd7f9dfe91f01cd56db0d64fe01b05eecae6ee3a
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Fri, 21 Oct 2022 09:53:05 +0300

Do not send "100 Continue" if request does not have a body

Diffstat:
Msrc/microhttpd/connection.c | 32+++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -765,17 +765,27 @@ need_100_continue (struct MHD_Connection *connection) { const char *expect; - return (MHD_IS_HTTP_VER_1_1_COMPAT (connection->rq.http_ver) && - (MHD_NO != - MHD_lookup_connection_value_n (connection, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_EXPECT, - MHD_STATICSTR_LEN_ ( - MHD_HTTP_HEADER_EXPECT), - &expect, - NULL)) && - (MHD_str_equal_caseless_ (expect, - "100-continue")) ); + if (! MHD_IS_HTTP_VER_1_1_COMPAT (connection->rq.http_ver)) + return false; + + if (0 == connection->rq.remaining_upload_size) + return false; + + if (MHD_NO == + MHD_lookup_connection_value_n (connection, + MHD_HEADER_KIND, + MHD_HTTP_HEADER_EXPECT, + MHD_STATICSTR_LEN_ ( \ + MHD_HTTP_HEADER_EXPECT), + &expect, + NULL)) + return false; + + if (MHD_str_equal_caseless_ (expect, + "100-continue")) + return true; + + return false; }