commit 746dae6ae094664c6ed0fa4bf5c98db7c758e8bc
parent e33dd19d70dbdb4156f6417b05f76495b2787245
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Sun, 17 Oct 2021 15:14:17 +0300
Added error response for wrong 'Content-Length' values
Diffstat:
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
@@ -115,6 +115,18 @@
#endif
/**
+ * Response text used when the request HTTP chunked encoding is
+ * malformed.
+ */
+#ifdef HAVE_MESSAGES
+#define REQUEST_CONTENTLENGTH_MALFORMED \
+ "<html><head><title>Request malformed</title></head>" \
+ "<body>Your HTTP request has wrong value for <b>Content-Length</b> header.</body></html>"
+#else
+#define REQUEST_CHUNKED_MALFORMED ""
+#endif
+
+/**
* Response text used when there is an internal server error.
*
* Intentionally empty here to keep our memory footprint
@@ -3505,8 +3517,9 @@ parse_connection_headers (struct MHD_Connection *connection)
_ (
"Failed to parse `Content-Length' header. Closing connection.\n"));
#endif
- CONNECTION_CLOSE_ERROR (connection,
- NULL);
+ transmit_error_response_static (connection,
+ MHD_HTTP_BAD_REQUEST,
+ REQUEST_CONTENTLENGTH_MALFORMED);
return;
}
}