gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (cb2d42d0 -> 3a02f18c)


From: gnunet
Subject: [libmicrohttpd] branch master updated (cb2d42d0 -> 3a02f18c)
Date: Sun, 17 Oct 2021 12:57:45 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from cb2d42d0 test_tricky: fixed copy-paste errors
     new 21cdab14 Transmit error reply to the clients if received broken 
chunked encoding
     new 3a02f18c Simplified connection.c code: reused error reply function

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/microhttpd/connection.c | 56 ++++++++++++++++++---------------------------
 1 file changed, 22 insertions(+), 34 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index da3fc1df..f973c93e 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -103,6 +103,17 @@
 #define REQUEST_MALFORMED ""
 #endif
 
+/**
+ * Response text used when the request HTTP chunked encoding is
+ * malformed.
+ */
+#ifdef HAVE_MESSAGES
+#define REQUEST_CHUNKED_MALFORMED \
+  "<html><head><title>Request malformed</title></head><body>Your HTTP chunked 
encoding was syntactically incorrect.</body></html>"
+#else
+#define REQUEST_CHUNKED_MALFORMED ""
+#endif
+
 /**
  * Response text used when there is an internal server error.
  *
@@ -3070,10 +3081,9 @@ process_request_body (struct MHD_Connection *connection)
         if (0 == i)
         {
           /* malformed encoding */
-          CONNECTION_CLOSE_ERROR (connection,
-                                  _ ("Received malformed HTTP request " \
-                                     "(bad chunked encoding). " \
-                                     "Closing connection."));
+          transmit_error_response_static (connection,
+                                          MHD_HTTP_BAD_REQUEST,
+                                          REQUEST_CHUNKED_MALFORMED);
           return;
         }
         available -= i;
@@ -3150,10 +3160,9 @@ process_request_body (struct MHD_Connection *connection)
         if (malformed)
         {
           /* malformed encoding */
-          CONNECTION_CLOSE_ERROR (connection,
-                                  _ ("Received malformed HTTP request " \
-                                     "(bad chunked encoding). " \
-                                     "Closing connection."));
+          transmit_error_response_static (connection,
+                                          MHD_HTTP_BAD_REQUEST,
+                                          REQUEST_CHUNKED_MALFORMED);
           return;
         }
         /* skip 2nd part of line feed */
@@ -3458,32 +3467,11 @@ parse_connection_headers (struct MHD_Connection 
*connection)
     connection->state = MHD_CONNECTION_FULL_REQ_RECEIVED;
 #ifdef HAVE_MESSAGES
     MHD_DLOG (connection->daemon,
-              _ ("Received HTTP 1.1 request without `Host' header.\n"));
+              _ ("Received HTTP/1.1 request without `Host' header.\n"));
 #endif
-    mhd_assert (NULL == connection->response);
-    response =
-      MHD_create_response_from_buffer (MHD_STATICSTR_LEN_ (REQUEST_LACKS_HOST),
-                                       REQUEST_LACKS_HOST,
-                                       MHD_RESPMEM_PERSISTENT);
-    if (NULL == response)
-    {
-      /* can't even send a reply, at least close the connection */
-      CONNECTION_CLOSE_ERROR (connection,
-                              _ (
-                                "Closing connection (failed to create 
response)."));
-      return;
-    }
-    iret = MHD_queue_response (connection,
-                               MHD_HTTP_BAD_REQUEST,
-                               response);
-    MHD_destroy_response (response);
-    if (MHD_NO == iret)
-    {
-      /* can't even send a reply, at least close the connection */
-      CONNECTION_CLOSE_ERROR (connection,
-                              _ (
-                                "Closing connection (failed to queue 
response)."));
-    }
+    transmit_error_response_static (connection,
+                                    MHD_HTTP_BAD_REQUEST,
+                                    REQUEST_LACKS_HOST);
     return;
   }
 
@@ -4383,7 +4371,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
       if (0 != connection->read_buffer_offset)
       {
         process_request_body (connection);           /* loop call */
-        if (MHD_CONNECTION_CLOSED == connection->state)
+        if (connection->stop_with_error)
           continue;
       }
       if ( (0 == connection->remaining_upload_size) ||

-- 
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]