gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 04/05: connection: reject or log requests with both chun


From: gnunet
Subject: [libmicrohttpd] 04/05: connection: reject or log requests with both chunked encoding and Content-Length
Date: Sun, 06 Nov 2022 13:10: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 099b50e44a6e3813256349516d1f87953a7bda47
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Fri Nov 4 17:07:34 2022 +0300

    connection: reject or log requests with both chunked encoding and 
Content-Length
---
 src/microhttpd/connection.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 704d6bcf..19d1c699 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -102,6 +102,21 @@
 #define REQUEST_UNSUPPORTED_TR_ENCODING ""
 #endif
 
+/**
+ * Response text used when the request has unsupported both headers:
+ * "Transfer-Enconding:" and "Content-Length:"
+ */
+#ifdef HAVE_MESSAGES
+#define REQUEST_LENGTH_WITH_TR_ENCODING \
+  "<html>" \
+  "<head><title>Malformed request</title></head>" \
+  "<body>Wrong combination of the request headers: both Transfer-Encoding " \
+  "and Content-Length headers are used at the same time.</body>" \
+  "</html>"
+#else
+#define REQUEST_LENGTH_WITH_TR_ENCODING ""
+#endif
+
 /**
  * Response text used when the request (http header) is
  * malformed.
@@ -3996,6 +4011,33 @@ parse_connection_headers (struct MHD_Connection 
*connection)
                                       REQUEST_UNSUPPORTED_TR_ENCODING);
       return;
     }
+    else if (MHD_NO !=
+             MHD_lookup_connection_value_n (connection,
+                                            MHD_HEADER_KIND,
+                                            MHD_HTTP_HEADER_CONTENT_LENGTH,
+                                            MHD_STATICSTR_LEN_ ( \
+                                              MHD_HTTP_HEADER_CONTENT_LENGTH),
+                                            NULL,
+                                            NULL))
+    {
+      /* TODO: add individual settings */
+      if (1 <= connection->daemon->strict_for_client)
+      {
+        transmit_error_response_static (connection,
+                                        MHD_HTTP_BAD_REQUEST,
+                                        REQUEST_LENGTH_WITH_TR_ENCODING);
+        return;
+      }
+#ifdef HAVE_MESSAGES
+      else
+      {
+        MHD_DLOG (connection->daemon,
+                  _ ("The 'Content-Length' request header is ignored "
+                     "as chunked Transfer-Encoding is used "
+                     "for this request.\n"));
+      }
+#endif /* HAVE_MESSAGES */
+    }
     connection->rq.have_chunked_upload = true;
     connection->rq.remaining_upload_size = MHD_SIZE_UNKNOWN;
   }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]