libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit a120d27045cb9f5408a07cf2df0716ba7b3eabf4
parent 179f57bce2592b13dc7f07d6377ac9916faa32d2
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sun, 13 Dec 2020 19:50:12 +0300

mhd_send.c: renamed function, moved doxy

Function MHD_send_on_connection_() renamed to a shorte MHD_send_data_().
Doxy moved to the header.
Removed declaration of unused enum MHD_SendSocketOptions.

Diffstat:
Msrc/microhttpd/connection.c | 48++++++++++++++++++++++++------------------------
Msrc/microhttpd/mhd_send.c | 44++++++++++++--------------------------------
Msrc/microhttpd/mhd_send.h | 57++++++++++++++++++++++++---------------------------------
3 files changed, 60 insertions(+), 89 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -2877,12 +2877,12 @@ MHD_connection_handle_write (struct MHD_Connection *connection) case MHD_CONNECTION_HEADERS_PROCESSED: return; case MHD_CONNECTION_CONTINUE_SENDING: - ret = MHD_send_on_connection_ (connection, - &HTTP_100_CONTINUE - [connection->continue_message_write_offset], - MHD_STATICSTR_LEN_ (HTTP_100_CONTINUE) - - connection->continue_message_write_offset, - true); + ret = MHD_send_data_ (connection, + &HTTP_100_CONTINUE + [connection->continue_message_write_offset], + MHD_STATICSTR_LEN_ (HTTP_100_CONTINUE) + - connection->continue_message_write_offset, + true); if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) @@ -3020,12 +3020,12 @@ MHD_connection_handle_write (struct MHD_Connection *connection) - response->data_start; if (data_write_offset > (uint64_t) SIZE_MAX) MHD_PANIC (_ ("Data offset exceeds limit.\n")); - ret = MHD_send_on_connection_ (connection, - &response->data - [(size_t) data_write_offset], - response->data_size - - (size_t) data_write_offset, - true); + ret = MHD_send_data_ (connection, + &response->data + [(size_t) data_write_offset], + response->data_size + - (size_t) data_write_offset, + true); #if _MHD_DEBUG_SEND_DATA if (ret > 0) fprintf (stderr, @@ -3064,12 +3064,12 @@ MHD_connection_handle_write (struct MHD_Connection *connection) mhd_assert (0); return; case MHD_CONNECTION_CHUNKED_BODY_READY: - ret = MHD_send_on_connection_ (connection, - &connection->write_buffer - [connection->write_buffer_send_offset], - connection->write_buffer_append_offset - - connection->write_buffer_send_offset, - true); + ret = MHD_send_data_ (connection, + &connection->write_buffer + [connection->write_buffer_send_offset], + connection->write_buffer_append_offset + - connection->write_buffer_send_offset, + true); if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) @@ -3094,12 +3094,12 @@ MHD_connection_handle_write (struct MHD_Connection *connection) mhd_assert (0); return; case MHD_CONNECTION_FOOTERS_SENDING: - ret = MHD_send_on_connection_ (connection, - &connection->write_buffer - [connection->write_buffer_send_offset], - connection->write_buffer_append_offset - - connection->write_buffer_send_offset, - true); + ret = MHD_send_data_ (connection, + &connection->write_buffer + [connection->write_buffer_send_offset], + connection->write_buffer_append_offset + - connection->write_buffer_send_offset, + true); if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c @@ -660,25 +660,11 @@ post_send_setopt (struct MHD_Connection *connection, } -/** - * Send buffer to the client, push data from network buffer if requested - * and full buffer is sent. - * - * @param connection the MHD_Connection structure - * @param buffer content of the buffer to send - * @param buffer_size the size of the @a buffer (in bytes) - * @param push_data set to true to force push the data to the network from - * system buffers (usually set for the last piece of data), - * set to false to prefer holding incomplete network packets - * (more data will be send for the same reply). - * @return sum of the number of bytes sent from both buffers or - * error code (negative) - */ ssize_t -MHD_send_on_connection_ (struct MHD_Connection *connection, - const char *buffer, - size_t buffer_size, - bool push_data) +MHD_send_data_ (struct MHD_Connection *connection, + const char *buffer, + size_t buffer_size, + bool push_data) { MHD_socket s = connection->socket_fd; ssize_t ret; @@ -865,10 +851,10 @@ MHD_send_hdr_and_body_ (struct MHD_Connection *connection, #endif /* ! (HAVE_SENDMSG || HAVE_WRITEV) */ ) { - ret = MHD_send_on_connection_ (connection, - header, - header_size, - push_hdr); + ret = MHD_send_data_ (connection, + header, + header_size, + push_hdr); if ( ((size_t) header_size == ret) && (((size_t) SSIZE_MAX > header_size)) && (0 != body_size) ) @@ -885,10 +871,10 @@ MHD_send_hdr_and_body_ (struct MHD_Connection *connection, push_body = complete_response; } - ret2 = MHD_send_on_connection_ (connection, - body, - body_size, - push_body); + ret2 = MHD_send_data_ (connection, + body, + body_size, + push_body); if (0 < ret2) return ret + ret2; /* Total data sent */ if (MHD_ERR_AGAIN_ == ret2) @@ -1000,12 +986,6 @@ MHD_send_hdr_and_body_ (struct MHD_Connection *connection, #if defined(_MHD_HAVE_SENDFILE) -/** - * Function for sending responses backed by file FD. - * - * @param connection the MHD connection structure - * @return actual number of bytes sent - */ ssize_t MHD_send_sendfile_ (struct MHD_Connection *connection) { diff --git a/src/microhttpd/mhd_send.h b/src/microhttpd/mhd_send.h @@ -1,7 +1,7 @@ /* This file is part of libmicrohttpd + Copyright (C) 2017, 2020 Karlson2k (Evgeny Grin) Copyright (C) 2019 ng0 - Copyright (C) 2017 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -50,41 +50,26 @@ MHD_send_init_static_vars_ (void); #endif /* HAVE_FREEBSD_SENDFILE */ + /** - * The enumeration of send socket options. + * Send buffer to the client, push data from network buffer if requested + * and full buffer is sent. + * + * @param connection the MHD_Connection structure + * @param buffer content of the buffer to send + * @param buffer_size the size of the @a buffer (in bytes) + * @param push_data set to true to force push the data to the network from + * system buffers (usually set for the last piece of data), + * set to false to prefer holding incomplete network packets + * (more data will be send for the same reply). + * @return sum of the number of bytes sent from both buffers or + * error code (negative) */ -enum MHD_SendSocketOptions -{ - /** - * Need to flush buffers after send to push data to the network. - * Used to avoid delay before the last part of data (which is usually - * incomplete IP packet / MSS) is pushed by kernel to the network. - */ - MHD_SSO_PUSH_DATA = 0, - /** - * Buffer data if possible. - * If more response data is to be sent than try to buffer data in - * the local buffers so kernel able to send complete packets with - * lower overhead. - */ - MHD_SSO_PREFER_BUFF = 1, - /** - * consider tcpi_snd_mss and consider not corking for the header - * part if the size of the header is close to the MSS. - * Only used if we are NOT doing 100 Continue and are still - * sending the header (provided in full as the buffer to - * MHD_send_on_connection_ or as the header to - * MHD_send_on_connection2_). - */ - MHD_SSO_HDR_CORK = 2 -}; - - ssize_t -MHD_send_on_connection_ (struct MHD_Connection *connection, - const char *buffer, - size_t buffer_size, - bool push_data); +MHD_send_data_ (struct MHD_Connection *connection, + const char *buffer, + size_t buffer_size, + bool push_data); /** @@ -115,6 +100,12 @@ MHD_send_hdr_and_body_ (struct MHD_Connection *connection, bool complete_response); #if defined(_MHD_HAVE_SENDFILE) +/** + * Function for sending responses backed by file FD. + * + * @param connection the MHD connection structure + * @return actual number of bytes sent + */ ssize_t MHD_send_sendfile_ (struct MHD_Connection *connection);