[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 02/02: connection.c: minor updates: used new reply flags
From: |
gnunet |
Subject: |
[libmicrohttpd] 02/02: connection.c: minor updates: used new reply flags, added asserts and TODOs |
Date: |
Sat, 21 Aug 2021 13:31:49 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit d8ea84fd6dfa35ca125ea61d47a35835f32bdd0a
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sat Aug 21 14:28:05 2021 +0300
connection.c: minor updates: used new reply flags, added asserts and TODOs
---
src/microhttpd/connection.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index df17fa61..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);
@@ -3646,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->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,
@@ -3677,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)
@@ -3705,6 +3714,7 @@ MHD_connection_handle_write (struct MHD_Connection
*connection)
* update both offsets. */
mhd_assert (0 == connection->response_write_position);
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;
}
@@ -4863,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)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.