gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (5f9f3f06 -> e09b6df6)


From: gnunet
Subject: [libmicrohttpd] branch master updated (5f9f3f06 -> e09b6df6)
Date: Sat, 12 Dec 2020 16:45:46 +0100

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 5f9f3f06 fixed: really use sendmsg() for header and body
     new ca8693da struct MHD_Response: minor clarification
     new 3b435274 Simplified call of MHD_send_on_connection2_()
     new e09b6df6 Fixed sending response body for the HEAD requests

The 3 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 | 43 ++++++++++++++++++++++++++++---------------
 src/microhttpd/internal.h   |  2 +-
 src/microhttpd/mhd_send.c   |  1 +
 src/microhttpd/response.c   |  2 ++
 4 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 20e31998..8a06f7e2 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2917,24 +2917,37 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
                               - connection->write_buffer_send_offset;
       mhd_assert (connection->write_buffer_append_offset >= \
                   connection->write_buffer_send_offset);
-
-      /* if the response body is not available, we use 
MHD_send_on_connection_() */
-      if (NULL != connection->response->crc)
+      mhd_assert (NULL != connection->response);
+      mhd_assert ( (0 == connection->response->data_size) || \
+                   (0 == connection->response->data_start) );
+      mhd_assert ( (0 == connection->response_write_position) || \
+                   (response->total_size ==
+                    connection->response_write_position) || \
+                   (MHD_SIZE_UNKNOWN ==
+                    connection->response_write_position) );
+
+      if (0 == connection->response_write_position)
       {
-        ret = MHD_send_on_connection_ (connection,
-                                       &connection->write_buffer
-                                       [connection->write_buffer_send_offset],
-                                       wb_ready,
-                                       MHD_SSO_PREFER_BUFF);
+        /* Send response headers alongside the response body, if the body
+         * data is available. */
+        ret = MHD_send_on_connection2_ (connection,
+                                        &connection->write_buffer
+                                        [connection->write_buffer_send_offset],
+                                        wb_ready,
+                                        connection->response->data,
+                                        connection->response->data_size);
       }
       else
       {
+        /* This is response for HEAD request or reply body is not allowed
+         * for any other reason. */
+        /* Do not send the body data even if it's available. */
         ret = MHD_send_on_connection2_ (connection,
                                         &connection->write_buffer
                                         [connection->write_buffer_send_offset],
                                         wb_ready,
-                                        connection->response->data,
-                                        connection->response->data_size);
+                                        NULL,
+                                        0);
       }
 
       if (ret < 0)
@@ -2949,12 +2962,12 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
       /* 'ret' is not negative, it's safe to cast it to 'size_t'. */
       if (((size_t) ret) > wb_ready)
       {
-        mhd_assert (NULL == connection->response->crc);
-        /* We sent not just header data but also some response data,
-           update both offsets! */
+        /* 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);
         connection->write_buffer_send_offset += wb_ready;
-        ret -= wb_ready;
-        connection->response_write_position += ret;
+        connection->response_write_position = ret - wb_ready;
       }
       else
         connection->write_buffer_send_offset += ret;
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index d59735b5..a92f46f2 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -425,7 +425,7 @@ struct MHD_Response
   size_t data_size;
 
   /**
-   * Size of the data buffer @e data.
+   * Size of the writable data buffer @e data.
    */
   size_t data_buffer_size;
 
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 2bf9a071..f0cdfb58 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -841,6 +841,7 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection,
   const bool no_vec = false;
 #endif /* ! HTTPS_SUPPORT */
 #endif /* HAVE_SENDMSG || HAVE_WRITEV */
+  mhd_assert ( (NULL != buffer) || (0 == buffer_size) );
 
   if (
 #if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV)
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index b857326f..f4dc361c 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -781,6 +781,8 @@ MHD_create_response_from_data (size_t size,
   response->total_size = size;
   response->data = data;
   response->data_size = size;
+  if (must_copy)
+    response->data_buffer_size = size;
   return response;
 }
 

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