gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 01/02: Make sure that some space for request body is alw


From: gnunet
Subject: [libmicrohttpd] 01/02: Make sure that some space for request body is always available
Date: Mon, 03 Jul 2023 10:40:19 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 021923493ba4e90f525591b4a6698bf68b595ce4
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Thu Jun 22 14:13:57 2023 +0300

    Make sure that some space for request body is always available
---
 src/microhttpd/connection.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 4d912ce8..52dbfb3f 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -5543,9 +5543,37 @@ get_req_headers (struct MHD_Connection *c, bool 
process_footers)
   {
     c->rq.header_size = (size_t) (c->read_buffer - c->rq.method);
     c->state = MHD_CONNECTION_HEADERS_RECEIVED;
+
+    if (MHD_BUF_INC_SIZE > c->read_buffer_size)
+    {
+      /* Try to re-use some of the last bytes of the request header */
+      /* Do this only if space in the read buffer is limited AND
+         amount of read ahead data is small. */
+      /**
+       *  The position of the terminating NUL after the last character of
+       *  the last header element.
+       */
+      const char *last_elmnt_end;
+      size_t shift_back_size;
+      if (NULL != c->rq.headers_received_tail)
+        last_elmnt_end =
+          c->rq.headers_received_tail->value
+          + c->rq.headers_received_tail->value_size;
+      else
+        last_elmnt_end = c->rq.version + HTTP_VER_LEN;
+      mhd_assert ((last_elmnt_end + 1) < c->read_buffer);
+      shift_back_size = (size_t) (c->read_buffer - (last_elmnt_end + 1));
+      if (0 != c->read_buffer_offset)
+        memmove (c->read_buffer - shift_back_size,
+                 c->read_buffer,
+                 c->read_buffer_offset);
+      c->read_buffer -= shift_back_size;
+      c->read_buffer_size += shift_back_size;
+    }
   }
   else
     c->state = MHD_CONNECTION_FOOTERS_RECEIVED;
+
   return true;
 }
 

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