gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (5d35f4f7 -> d8ea84fd)


From: gnunet
Subject: [libmicrohttpd] branch master updated (5d35f4f7 -> d8ea84fd)
Date: Sat, 21 Aug 2021 13:31:47 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 5d35f4f7 replies: fixed HTTP/1.0 keep-alive replies
     new 08d144ba Do not use the same flag for chunked request and chunked reply
     new d8ea84fd connection.c: minor updates: used new reply flags, added 
asserts and TODOs

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 | 49 ++++++++++++++++++++++++++-------------------
 src/microhttpd/internal.h   | 13 +++++++-----
 2 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 25cfe64b..7db660cb 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -905,9 +905,12 @@ try_ready_normal_body (struct MHD_Connection *connection)
   struct MHD_Response *response;
 
   response = connection->response;
+  mhd_assert (connection->rp_props.send_reply_body);
+
   if ( (0 == response->total_size) ||
+                     /* TODO: replace the next check with assert */
        (connection->response_write_position == response->total_size) )
-    return MHD_YES; /* 0-byte response is always ready */
+    return MHD_YES;  /* 0-byte response is always ready */
   if (NULL != response->data_iov)
   {
     size_t copy_size;
@@ -958,6 +961,8 @@ try_ready_normal_body (struct MHD_Connection *connection)
        (((ssize_t) MHD_CONTENT_READER_END_WITH_ERROR) == ret) )
   {
     /* either error or http 1.0 transfer, close socket! */
+    /* TODO: do not update total size, check whether response
+     * was really with unknown size */
     response->total_size = connection->response_write_position;
 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
     MHD_mutex_unlock_chk_ (&response->mutex);
@@ -1094,6 +1099,7 @@ try_ready_chunked_body (struct MHD_Connection *connection,
   if ( ((ssize_t) MHD_CONTENT_READER_END_WITH_ERROR) == ret)
   {
     /* error, close socket! */
+    /* TODO: remove update of the response size */
     response->total_size = connection->response_write_position;
 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
     MHD_mutex_unlock_chk_ (&response->mutex);
@@ -1655,8 +1661,6 @@ setup_reply_properties (struct MHD_Connection *connection)
 
   c->rp_props.chunked = use_chunked;
   c->rp_props.set = true;
-  /* TODO: remove 'have_chunked_upload' assignment, use 'rp_props.chunked' */
-  c->have_chunked_upload = c->rp_props.chunked;
 }
 
 
@@ -1884,7 +1888,6 @@ build_header_response (struct MHD_Connection *connection)
     use_conn_k_alive = false;
   }
 
-
   /* ** Actually build the response header ** */
 
   /* Get all space available */
@@ -2051,8 +2054,7 @@ build_connection_chunked_response_footer (struct 
MHD_Connection *connection)
   struct MHD_Connection *const c = connection; /**< a short alias */
   struct MHD_HTTP_Header *pos;
 
-  /* TODO: replace with 'use_chunked_send' */
-  mhd_assert (connection->have_chunked_upload);
+  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);
@@ -3650,13 +3652,18 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
                     connection->response_write_position) || \
                    (MHD_SIZE_UNKNOWN ==
                     connection->response_write_position) );
+      mhd_assert ((MHD_CONN_MUST_UPGRADE != connection->keepalive) || \
+                  (! connection->rp_props.send_reply_body));
 
-      if ( (NULL == resp->crc) &&
+      if ( (connection->rp_props.send_reply_body) &&
+           (NULL == resp->crc) &&
            (NULL == resp->data_iov) &&
+           /* TODO: remove the next check as 'send_reply_body' is used */
            (0 == connection->response_write_position) &&
-           (! connection->have_chunked_upload) )
+           (! connection->rp_props.chunked) )
       {
         mhd_assert (resp->total_size >= resp->data_size);
+        mhd_assert (0 == resp->data_start);
         /* Send response headers alongside the response body, if the body
          * data is available. */
         ret = MHD_send_hdr_and_body_ (connection,
@@ -3681,10 +3688,8 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
                                       NULL,
                                       0,
                                       ((0 == resp->total_size) ||
-                                       (resp->total_size ==
-                                        connection->response_write_position) ||
-                                       (MHD_SIZE_UNKNOWN ==
-                                        connection->response_write_position)));
+                                       (! connection->rp_props.send_reply_body)
+                                      ));
       }
 
       if (ret < 0)
@@ -3708,7 +3713,8 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
         /* The complete header and some response data have been sent,
          * update both offsets. */
         mhd_assert (0 == connection->response_write_position);
-        mhd_assert (! connection->have_chunked_upload);
+        mhd_assert (! connection->rp_props.chunked);
+        mhd_assert (connection->rp_props.send_reply_body);
         connection->write_buffer_send_offset += wb_ready;
         connection->response_write_position = ret - wb_ready;
       }
@@ -4029,13 +4035,13 @@ connection_reset (struct MHD_Connection *connection,
                         new_read_buf_size);
     c->read_buffer_size = new_read_buf_size;
     c->continue_message_write_offset = 0;
-    c->responseCode = 0;
     c->headers_received = NULL;
     c->headers_received_tail = NULL;
-    c->response_write_position = 0;
     c->have_chunked_upload = false;
     c->current_chunk_size = 0;
     c->current_chunk_offset = 0;
+    c->responseCode = 0;
+    c->response_write_position = 0;
     c->method = NULL;
     c->http_mthd = MHD_HTTP_MTHD_NO_METHOD;
     c->url = NULL;
@@ -4356,7 +4362,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
       }
 #endif /* UPGRADE_SUPPORT */
 
-      if (connection->have_chunked_upload)
+      if (connection->rp_props.chunked)
         connection->state = MHD_CONNECTION_CHUNKED_BODY_UNREADY;
       else
         connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY;
@@ -4375,8 +4381,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
         if (NULL != connection->response->crc)
           MHD_mutex_unlock_chk_ (&connection->response->mutex);
 #endif
-        /* TODO: replace with 'use_chunked_send' */
-        if (connection->have_chunked_upload)
+        if (connection->rp_props.chunked)
           connection->state = MHD_CONNECTION_BODY_SENT;
         else
           connection->state = MHD_CONNECTION_FOOTERS_SENT;
@@ -4432,8 +4437,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
       }
       break;
     case MHD_CONNECTION_BODY_SENT:
-      /* TODO: replace with 'use_chunked_send' */
-      mhd_assert (connection->have_chunked_upload);
+      mhd_assert (connection->rp_props.chunked);
 
       if (MHD_NO == build_connection_chunked_response_footer (connection))
       {
@@ -4443,7 +4447,8 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
                                   "Closing connection (failed to create 
response footer)."));
         continue;
       }
-      if ( (! connection->have_chunked_upload) ||
+      /* 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;
@@ -4868,6 +4873,8 @@ MHD_queue_response (struct MHD_Connection *connection,
     /* if this is a "HEAD" request, or a status code for
        which a body is not allowed, pretend that we
        have already sent the full message body. */
+    /* TODO: remove the next assignment, use 'rp_props.send_reply_body' in
+     * checks */
     connection->response_write_position = response->total_size;
   }
   if (MHD_CONNECTION_HEADERS_PROCESSED == connection->state)
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index fc521832..1524ced3 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -1233,11 +1233,14 @@ struct MHD_Connection
   struct MHD_Reply_Properties rp_props;
 
   /**
-   * Are we receiving with chunked encoding?  This will be set to
-   * #MHD_YES after we parse the headers and are processing the body
-   * with chunks.  After we are done with the body and we are
-   * processing the footers; once the footers are also done, this will
-   * be set to #MHD_NO again (before the final call to the handler).
+   * Are we receiving with chunked encoding?
+   * This will be set to #MHD_YES after we parse the headers and
+   * are processing the body with chunks.
+   * After we are done with the body and we are processing the footers;
+   * once the footers are also done, this will be set to #MHD_NO again
+   * (before the final call to the handler).
+   * It is used only for requests, chunked encoding for response is
+   * indicated by @a rp_props.
    */
   bool have_chunked_upload;
 

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