diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2020-12-12 17:39:09 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2020-12-12 17:39:09 +0300 |
commit | 3b435274a2b3cd206201cc6140f2c70016a03bd2 (patch) | |
tree | eb2c14c55844c59e2f82c1a08ef92b4a88a32c3e | |
parent | ca8693dacc59ec797f2a47518fe3b34456b67836 (diff) | |
download | libmicrohttpd-3b435274a2b3cd206201cc6140f2c70016a03bd2.tar.gz libmicrohttpd-3b435274a2b3cd206201cc6140f2c70016a03bd2.zip |
Simplified call of MHD_send_on_connection2_()
-rw-r--r-- | src/microhttpd/connection.c | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 20e31998..74f07408 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -2917,25 +2917,18 @@ MHD_connection_handle_write (struct MHD_Connection *connection) | |||
2917 | - connection->write_buffer_send_offset; | 2917 | - connection->write_buffer_send_offset; |
2918 | mhd_assert (connection->write_buffer_append_offset >= \ | 2918 | mhd_assert (connection->write_buffer_append_offset >= \ |
2919 | connection->write_buffer_send_offset); | 2919 | connection->write_buffer_send_offset); |
2920 | 2920 | mhd_assert (NULL != connection->response); | |
2921 | /* if the response body is not available, we use MHD_send_on_connection_() */ | 2921 | mhd_assert ( (0 == connection->response->data_size) || \ |
2922 | if (NULL != connection->response->crc) | 2922 | (0 == connection->response->data_start) ); |
2923 | { | 2923 | |
2924 | ret = MHD_send_on_connection_ (connection, | 2924 | /* Send response headers alongside the response body, if the body |
2925 | &connection->write_buffer | 2925 | * data is available. */ |
2926 | [connection->write_buffer_send_offset], | 2926 | ret = MHD_send_on_connection2_ (connection, |
2927 | wb_ready, | 2927 | &connection->write_buffer |
2928 | MHD_SSO_PREFER_BUFF); | 2928 | [connection->write_buffer_send_offset], |
2929 | } | 2929 | wb_ready, |
2930 | else | 2930 | connection->response->data, |
2931 | { | 2931 | connection->response->data_size); |
2932 | ret = MHD_send_on_connection2_ (connection, | ||
2933 | &connection->write_buffer | ||
2934 | [connection->write_buffer_send_offset], | ||
2935 | wb_ready, | ||
2936 | connection->response->data, | ||
2937 | connection->response->data_size); | ||
2938 | } | ||
2939 | 2932 | ||
2940 | if (ret < 0) | 2933 | if (ret < 0) |
2941 | { | 2934 | { |
@@ -2949,12 +2942,11 @@ MHD_connection_handle_write (struct MHD_Connection *connection) | |||
2949 | /* 'ret' is not negative, it's safe to cast it to 'size_t'. */ | 2942 | /* 'ret' is not negative, it's safe to cast it to 'size_t'. */ |
2950 | if (((size_t) ret) > wb_ready) | 2943 | if (((size_t) ret) > wb_ready) |
2951 | { | 2944 | { |
2952 | mhd_assert (NULL == connection->response->crc); | 2945 | /* The complete header and some response data have been sent, |
2953 | /* We sent not just header data but also some response data, | 2946 | * update both offsets. */ |
2954 | update both offsets! */ | 2947 | mhd_assert (! connection->have_chunked_upload); |
2955 | connection->write_buffer_send_offset += wb_ready; | 2948 | connection->write_buffer_send_offset += wb_ready; |
2956 | ret -= wb_ready; | 2949 | connection->response_write_position += ret - wb_ready; |
2957 | connection->response_write_position += ret; | ||
2958 | } | 2950 | } |
2959 | else | 2951 | else |
2960 | connection->write_buffer_send_offset += ret; | 2952 | connection->write_buffer_send_offset += ret; |