libmicrohttpd

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

commit 51cfb23f17b55708fb569b46df90914e70b5a077
parent 3d6e8187a816d1e5f1617604b090c220d5cd4ea5
Author: ng0 <ng0@n0.is>
Date:   Wed, 24 Jul 2019 15:05:51 +0000

first attempt to add MHD_send_on_connection2_

Diffstat:
Msrc/microhttpd/connection.c | 34++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -3408,20 +3408,26 @@ MHD_connection_handle_write (struct MHD_Connection *connection) mhd_assert (0); return; case MHD_CONNECTION_HEADERS_SENDING: - /* TODO: Maybe use MHD_send_on_connection2_()? */ - /* - ret = MHD_send_on_connection2_ (struct MHD_Connection *connection, - const char *header, - size_t header_size, - const char *buffer, - size_t buffer_size); - */ - ret = MHD_send_on_connection_ (connection, - &connection->write_buffer - [connection->write_buffer_send_offset], - connection->write_buffer_append_offset - - connection->write_buffer_send_offset, - MHD_SSO_MAY_CORK); + /* if the response body is not available, we use MHD_send_on_connection_() */ + if (sizeof(connection->response->data) <= 1024) /* bad magic number */ + { + ret = MHD_send_on_connection_ (connection, + &connection->write_buffer + [connection->write_buffer_send_offset], + connection->write_buffer_append_offset - + connection->write_buffer_send_offset, + MHD_SSO_MAY_CORK); + } + else + { + ret = MHD_send_on_connection2_ (connection, + &connection->write_buffer + [connection->write_buffer_send_offset], + connection->write_buffer_append_offset - + connection->write_buffer_send_offset, + response_body, + response_size); + } if (ret < 0) {