gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (77303a4a -> 889b74b6)


From: gnunet
Subject: [libmicrohttpd] branch master updated (77303a4a -> 889b74b6)
Date: Tue, 27 Sep 2022 18:02:14 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 77303a4a test_head: new test-case for HEAD requests
     new ad43f866 configure: fixed typos in messages
     new b9972291 Renamed request processing states for clarity and readability
     new 3a7126a3 Removed one debug member from release builds
     new dd5b0d64 connection.c: fixed typo in comment
     new 75d38521 connection.c: added asserts for connection's states 
processing logic
     new 889b74b6 connection.c: removed unused check for chunked replies

The 6 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:
 configure.ac                |  4 +--
 src/microhttpd/connection.c | 62 ++++++++++++++++++++++++++-------------------
 src/microhttpd/internal.c   |  8 +++---
 src/microhttpd/internal.h   | 18 ++++++++-----
 4 files changed, 53 insertions(+), 39 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1b6310da..6a13f469 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2858,7 +2858,7 @@ AS_IF([test "x$have_gnutls" != "xyes" && test 
"x$with_gnutls" = "xyes"],
             gnutls_free(data.data);
           ]])], [[have_gnutls_sni=yes]], [[have_gnutls_sni=no]])
      AC_MSG_RESULT([[$have_gnutls_sni]])
-     AC_CACHE_CHECK([[whether GnuTLS require libgcrypt initialisaion]], 
[mhd_cv_gcrypt_required],
+     AC_CACHE_CHECK([[whether GnuTLS require libgcrypt initialisation]], 
[mhd_cv_gcrypt_required],
        [
         AC_COMPILE_IFELSE(
           [
@@ -2868,7 +2868,7 @@ AS_IF([test "x$have_gnutls" != "xyes" && test 
"x$with_gnutls" = "xyes"],
              ],
              [
 #if !defined(GNUTLS_VERSION_NUMBER) || GNUTLS_VERSION_NUMBER+0 <= 0x020c14
-#error Old versions of GnuTLS require libgcript initialisaion
+#error Old versions of GnuTLS require libgcript initialisation
 choke me now
 #endif
              ]
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 7624711a..f187da59 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1823,7 +1823,9 @@ setup_reply_properties (struct MHD_Connection *connection)
     use_chunked = false; /* chunked encoding cannot be used without body */
 
   c->rp.props.chunked = use_chunked;
+#ifdef _DEBUG
   c->rp.props.set = true;
+#endif /* _DEBUG */
 }
 
 
@@ -2280,7 +2282,7 @@ build_connection_chunked_response_footer (struct 
MHD_Connection *connection)
   mhd_assert (connection->rp.props.chunked);
   /* TODO: allow combining of the final footer with the last chunk,
    * modify the next assert. */
-  mhd_assert (MHD_CONNECTION_BODY_SENT == connection->state);
+  mhd_assert (MHD_CONNECTION_CHUNKED_BODY_SENT == connection->state);
   mhd_assert (NULL != c->rp.response);
 
   buf_size = connection_maximize_write_buffer (c);
@@ -2624,13 +2626,13 @@ MHD_connection_update_event_loop_info (struct 
MHD_Connection *connection)
     case MHD_CONNECTION_CHUNKED_BODY_UNREADY:
       connection->event_loop_info = MHD_EVENT_LOOP_INFO_BLOCK;
       break;
-    case MHD_CONNECTION_BODY_SENT:
+    case MHD_CONNECTION_CHUNKED_BODY_SENT:
       mhd_assert (0);
       break;
     case MHD_CONNECTION_FOOTERS_SENDING:
       connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE;
       break;
-    case MHD_CONNECTION_FOOTERS_SENT:
+    case MHD_CONNECTION_FULL_REPLY_SENT:
       mhd_assert (0);
       break;
     case MHD_CONNECTION_CLOSED:
@@ -3153,7 +3155,7 @@ parse_http_version (struct MHD_Connection *connection,
   const char *const h = http_string; /**< short alias */
   mhd_assert (NULL != http_string);
 
-  /* String must starts with 'HTTP/d.d', case-sensetive match.
+  /* String must start with 'HTTP/d.d', case-sensetive match.
    * See https://datatracker.ietf.org/doc/html/rfc7230#section-2.6 */
   if ((len != 8) ||
       (h[0] != 'H') || (h[1] != 'T') || (h[2] != 'T') || (h[3] != 'P') ||
@@ -4208,9 +4210,9 @@ MHD_connection_handle_read (struct MHD_Connection 
*connection,
   case MHD_CONNECTION_NORMAL_BODY_READY:
   case MHD_CONNECTION_CHUNKED_BODY_UNREADY:
   case MHD_CONNECTION_CHUNKED_BODY_READY:
-  case MHD_CONNECTION_BODY_SENT:
+  case MHD_CONNECTION_CHUNKED_BODY_SENT:
   case MHD_CONNECTION_FOOTERS_SENDING:
-  case MHD_CONNECTION_FOOTERS_SENT:
+  case MHD_CONNECTION_FULL_REPLY_SENT:
   default:
     mhd_assert (0); /* Should not be possible */
   }
@@ -4466,7 +4468,7 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
     }
     if (connection->rp.rsp_write_position ==
         connection->rp.response->total_size)
-      connection->state = MHD_CONNECTION_FOOTERS_SENT;   /* have no footers */
+      connection->state = MHD_CONNECTION_FULL_REPLY_SENT;
     return;
   case MHD_CONNECTION_NORMAL_BODY_UNREADY:
     mhd_assert (0);
@@ -4500,11 +4502,11 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
     check_write_done (connection,
                       (connection->rp.response->total_size ==
                        connection->rp.rsp_write_position) ?
-                      MHD_CONNECTION_BODY_SENT :
+                      MHD_CONNECTION_CHUNKED_BODY_SENT :
                       MHD_CONNECTION_CHUNKED_BODY_UNREADY);
     return;
   case MHD_CONNECTION_CHUNKED_BODY_UNREADY:
-  case MHD_CONNECTION_BODY_SENT:
+  case MHD_CONNECTION_CHUNKED_BODY_SENT:
     mhd_assert (0);
     return;
   case MHD_CONNECTION_FOOTERS_SENDING:
@@ -4534,9 +4536,9 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
     if (MHD_CONNECTION_FOOTERS_SENDING != connection->state)
       return;
     check_write_done (connection,
-                      MHD_CONNECTION_FOOTERS_SENT);
+                      MHD_CONNECTION_FULL_REPLY_SENT);
     return;
-  case MHD_CONNECTION_FOOTERS_SENT:
+  case MHD_CONNECTION_FULL_REPLY_SENT:
     mhd_assert (0);
     return;
   case MHD_CONNECTION_CLOSED:
@@ -5065,7 +5067,6 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
       /* no default action */
       break;
     case MHD_CONNECTION_HEADERS_SENT:
-      /* Some clients may take some actions right after header receive */
 #ifdef UPGRADE_SUPPORT
       if (NULL != connection->rp.response->upgrade_handler)
       {
@@ -5099,12 +5100,16 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
           connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY;
       }
       else
-        connection->state = MHD_CONNECTION_FOOTERS_SENT;
+        connection->state = MHD_CONNECTION_FULL_REPLY_SENT;
       continue;
     case MHD_CONNECTION_NORMAL_BODY_READY:
+      mhd_assert (connection->rp.props.send_reply_body);
+      mhd_assert (! connection->rp.props.chunked);
       /* nothing to do here */
       break;
     case MHD_CONNECTION_NORMAL_BODY_UNREADY:
+      mhd_assert (connection->rp.props.send_reply_body);
+      mhd_assert (! connection->rp.props.chunked);
 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
       if (NULL != connection->rp.response->crc)
         MHD_mutex_lock_chk_ (&connection->rp.response->mutex);
@@ -5116,9 +5121,9 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
           MHD_mutex_unlock_chk_ (&connection->rp.response->mutex);
 #endif
         if (connection->rp.props.chunked)
-          connection->state = MHD_CONNECTION_BODY_SENT;
+          connection->state = MHD_CONNECTION_CHUNKED_BODY_SENT;
         else
-          connection->state = MHD_CONNECTION_FOOTERS_SENT;
+          connection->state = MHD_CONNECTION_FULL_REPLY_SENT;
         continue;
       }
       if (MHD_NO != try_ready_normal_body (connection))
@@ -5136,9 +5141,13 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
       /* not ready, no socket action */
       break;
     case MHD_CONNECTION_CHUNKED_BODY_READY:
+      mhd_assert (connection->rp.props.send_reply_body);
+      mhd_assert (connection->rp.props.chunked);
       /* nothing to do here */
       break;
     case MHD_CONNECTION_CHUNKED_BODY_UNREADY:
+      mhd_assert (connection->rp.props.send_reply_body);
+      mhd_assert (connection->rp.props.chunked);
 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
       if (NULL != connection->rp.response->crc)
         MHD_mutex_lock_chk_ (&connection->rp.response->mutex);
@@ -5151,7 +5160,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
         if (NULL != connection->rp.response->crc)
           MHD_mutex_unlock_chk_ (&connection->rp.response->mutex);
 #endif
-        connection->state = MHD_CONNECTION_BODY_SENT;
+        connection->state = MHD_CONNECTION_CHUNKED_BODY_SENT;
         continue;
       }
       if (1)
@@ -5163,15 +5172,18 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
           if (NULL != connection->rp.response->crc)
             MHD_mutex_unlock_chk_ (&connection->rp.response->mutex);
 #endif
-          connection->state = finished ? MHD_CONNECTION_BODY_SENT :
+          connection->state = finished ? MHD_CONNECTION_CHUNKED_BODY_SENT :
                               MHD_CONNECTION_CHUNKED_BODY_READY;
           continue;
         }
         /* mutex was already unlocked by try_ready_chunked_body */
       }
       break;
-    case MHD_CONNECTION_BODY_SENT:
+    case MHD_CONNECTION_CHUNKED_BODY_SENT:
+      mhd_assert (connection->rp.props.send_reply_body);
       mhd_assert (connection->rp.props.chunked);
+      mhd_assert (connection->write_buffer_send_offset <= \
+                  connection->write_buffer_append_offset);
 
       if (MHD_NO == build_connection_chunked_response_footer (connection))
       {
@@ -5181,18 +5193,16 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
                                   "Closing connection (failed to create 
response footer)."));
         continue;
       }
-      /* TODO: remove next 'if' */
-      if ( (! connection->rp.props.chunked) ||
-           (connection->write_buffer_send_offset ==
-            connection->write_buffer_append_offset) )
-        connection->state = MHD_CONNECTION_FOOTERS_SENT;
-      else
-        connection->state = MHD_CONNECTION_FOOTERS_SENDING;
+      mhd_assert (connection->write_buffer_send_offset < \
+                  connection->write_buffer_append_offset);
+      connection->state = MHD_CONNECTION_FOOTERS_SENDING;
       continue;
     case MHD_CONNECTION_FOOTERS_SENDING:
+      mhd_assert (connection->rp.props.send_reply_body);
+      mhd_assert (connection->rp.props.chunked);
       /* no default action */
       break;
-    case MHD_CONNECTION_FOOTERS_SENT:
+    case MHD_CONNECTION_FULL_REPLY_SENT:
       if (MHD_HTTP_PROCESSING == connection->rp.responseCode)
       {
         /* After this type of response, we allow sending another! */
diff --git a/src/microhttpd/internal.c b/src/microhttpd/internal.c
index 57553251..dee21e9e 100644
--- a/src/microhttpd/internal.c
+++ b/src/microhttpd/internal.c
@@ -75,12 +75,12 @@ MHD_state_to_string (enum MHD_CONNECTION_STATE state)
     return "chunked body unready";
   case MHD_CONNECTION_CHUNKED_BODY_READY:
     return "chunked body ready";
-  case MHD_CONNECTION_BODY_SENT:
-    return "body sent";
+  case MHD_CONNECTION_CHUNKED_BODY_SENT:
+    return "chunked body sent";
   case MHD_CONNECTION_FOOTERS_SENDING:
     return "footers sending";
-  case MHD_CONNECTION_FOOTERS_SENT:
-    return "footers sent";
+  case MHD_CONNECTION_FULL_REPLY_SENT:
+    return "reply sent completely";
   case MHD_CONNECTION_CLOSED:
     return "closed";
   default:
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index adb69b32..6a88177e 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -706,31 +706,33 @@ enum MHD_CONNECTION_STATE
   MHD_CONNECTION_CHUNKED_BODY_READY = MHD_CONNECTION_CHUNKED_BODY_UNREADY + 1,
 
   /**
-   * We have sent the response body. Prepare the footers.
+   * We have sent the chunked response body. Prepare the footers.
    */
-  MHD_CONNECTION_BODY_SENT = MHD_CONNECTION_CHUNKED_BODY_READY + 1,
+  MHD_CONNECTION_CHUNKED_BODY_SENT = MHD_CONNECTION_CHUNKED_BODY_READY + 1,
 
   /**
    * We have prepared the response footer.  Send it.
    */
-  MHD_CONNECTION_FOOTERS_SENDING = MHD_CONNECTION_BODY_SENT + 1,
+  MHD_CONNECTION_FOOTERS_SENDING = MHD_CONNECTION_CHUNKED_BODY_SENT + 1,
 
   /**
-   * We have sent the response footer.  Shutdown or restart.
+   * We have sent the entire reply.
+   * Shutdown connection or restart processing to get a new request.
    */
-  MHD_CONNECTION_FOOTERS_SENT = MHD_CONNECTION_FOOTERS_SENDING + 1,
+  MHD_CONNECTION_FULL_REPLY_SENT = MHD_CONNECTION_FOOTERS_SENDING + 1,
 
   /**
    * This connection is to be closed.
    */
-  MHD_CONNECTION_CLOSED = MHD_CONNECTION_FOOTERS_SENT + 1,
+  MHD_CONNECTION_CLOSED = MHD_CONNECTION_FULL_REPLY_SENT + 1
 
 #ifdef UPGRADE_SUPPORT
+  ,
   /**
    * Connection was "upgraded" and socket is now under the
    * control of the application.
    */
-  MHD_CONNECTION_UPGRADE
+  MHD_CONNECTION_UPGRADE = MHD_CONNECTION_CLOSED + 1
 #endif /* UPGRADE_SUPPORT */
 
 } _MHD_FIXED_ENUM;
@@ -1078,7 +1080,9 @@ struct MHD_Request
  */
 struct MHD_Reply_Properties
 {
+#ifdef _DEBUG
   bool set; /**< Indicates that other members are set and valid */
+#endif /* _DEBUG */
   bool use_reply_body_headers; /**< Use reply body-specific headers */
   bool send_reply_body; /**< Send reply body (can be zero-sized) */
   bool chunked; /**< Use chunked encoding for reply */

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