gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 02/02: Added new connection state MHD_CONNECTION_FULL_RE


From: gnunet
Subject: [libmicrohttpd] 02/02: Added new connection state MHD_CONNECTION_FULL_REQ_RECEIVED
Date: Sat, 21 Aug 2021 18:55:32 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit e76e18e4531c1d14c3796efd6ea75b8f54dcda23
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sat Aug 21 19:51:50 2021 +0300

    Added new connection state MHD_CONNECTION_FULL_REQ_RECEIVED
    
    The new state improved readability of the code.
---
 src/microhttpd/connection.c | 23 +++++++++++++++++------
 src/microhttpd/internal.h   | 11 ++++++++---
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index c5f86cc2..bd96b1cf 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2126,7 +2126,7 @@ transmit_error_response_len (struct MHD_Connection 
*connection,
   struct MHD_Response *response;
   enum MHD_Result iret;
 
-  connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
+  connection->state = MHD_CONNECTION_FULL_REQ_RECEIVED;
   connection->stop_with_error = true;
   if (0 != connection->read_buffer_size)
   {
@@ -2316,6 +2316,9 @@ MHD_connection_update_event_loop_info (struct 
MHD_Connection *connection)
          happens in read handler */
       break;
     case MHD_CONNECTION_FOOTERS_RECEIVED:
+      mhd_assert (0);
+      break;
+    case MHD_CONNECTION_FULL_REQ_RECEIVED:
       connection->event_loop_info = MHD_EVENT_LOOP_INFO_BLOCK;
       break;
     case MHD_CONNECTION_HEADERS_SENDING:
@@ -3329,7 +3332,7 @@ parse_connection_headers (struct MHD_Connection 
*connection)
     enum MHD_Result iret;
 
     /* die, http 1.1 request without host and we are pedantic */
-    connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
+    connection->state = MHD_CONNECTION_FULL_REQ_RECEIVED;
     connection->stop_with_error = true;
 #ifdef HAVE_MESSAGES
     MHD_DLOG (connection->daemon,
@@ -3640,6 +3643,7 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
   case MHD_CONNECTION_BODY_RECEIVED:
   case MHD_CONNECTION_FOOTER_PART_RECEIVED:
   case MHD_CONNECTION_FOOTERS_RECEIVED:
+  case MHD_CONNECTION_FULL_REQ_RECEIVED:
     mhd_assert (0);
     return;
   case MHD_CONNECTION_HEADERS_SENDING:
@@ -4229,7 +4233,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
         connection->stop_with_error = true;
       }
       connection->state = (0 == connection->remaining_upload_size)
-                          ? MHD_CONNECTION_FOOTERS_RECEIVED
+                          ? MHD_CONNECTION_FULL_REQ_RECEIVED
                           : MHD_CONNECTION_CONTINUE_SENT;
       if (connection->suspended)
         break;
@@ -4258,7 +4262,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
              (! connection->stop_with_error) )
           connection->state = MHD_CONNECTION_BODY_RECEIVED;
         else
-          connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
+          connection->state = MHD_CONNECTION_FULL_REQ_RECEIVED;
         if (connection->suspended)
           break;
         continue;
@@ -4277,6 +4281,8 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
                                   NULL);
           continue;
         }
+        if (0 < connection->read_buffer_offset)
+          connection->state = MHD_CONNECTION_FOOTER_PART_RECEIVED;
         break;
       }
       if (0 == line[0])
@@ -4325,6 +4331,11 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
       }
       continue;
     case MHD_CONNECTION_FOOTERS_RECEIVED:
+      /* The header, the body, and the footers of the request has been 
received,
+       * switch to the final processing of the request. */
+      connection->state = MHD_CONNECTION_FULL_REQ_RECEIVED;
+      continue;
+    case MHD_CONNECTION_FULL_REQ_RECEIVED:
       call_connection_handler (connection);     /* "final" call */
       if (connection->state == MHD_CONNECTION_CLOSED)
         continue;
@@ -4760,7 +4771,7 @@ MHD_queue_response (struct MHD_Connection *connection,
        (NULL == response) ||
        (NULL != connection->response) ||
        ( (MHD_CONNECTION_HEADERS_PROCESSED != connection->state) &&
-         (MHD_CONNECTION_FOOTERS_RECEIVED != connection->state) ) )
+         (MHD_CONNECTION_FULL_REQ_RECEIVED != connection->state) ) )
     return MHD_NO;
 
 #ifdef UPGRADE_SUPPORT
@@ -4893,7 +4904,7 @@ MHD_queue_response (struct MHD_Connection *connection,
     /* response was queued "early", refuse to read body / footers or
        further requests! */
     connection->stop_with_error = true;
-    connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
+    connection->state = MHD_CONNECTION_FULL_REQ_RECEIVED;
     connection->remaining_upload_size = 0;
   }
   if (! connection->in_idle)
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index ae91719e..ca317748 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -616,16 +616,21 @@ enum MHD_CONNECTION_STATE
   MHD_CONNECTION_FOOTER_PART_RECEIVED = MHD_CONNECTION_BODY_RECEIVED + 1,
 
   /**
-   * We received the entire footer.  Wait for a response to be queued
-   * and prepare the response headers.
+   * We received the entire footer.
    */
   MHD_CONNECTION_FOOTERS_RECEIVED = MHD_CONNECTION_FOOTER_PART_RECEIVED + 1,
 
+  /**
+   * We received the entire request.
+   * Wait for a response to be queued and prepare the response headers.
+   */
+  MHD_CONNECTION_FULL_REQ_RECEIVED = MHD_CONNECTION_FOOTERS_RECEIVED + 1,
+
   /**
    * We have prepared the response headers in the writ buffer.
    * Send the response headers.
    */
-  MHD_CONNECTION_HEADERS_SENDING = MHD_CONNECTION_FOOTERS_RECEIVED + 1,
+  MHD_CONNECTION_HEADERS_SENDING = MHD_CONNECTION_FULL_REQ_RECEIVED + 1,
 
   /**
    * We have sent the response headers.  Get ready to send the body.

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