diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index b2197310..21f5a651 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c @@ -2441,7 +2441,10 @@ check_write_done (struct MHD_Connection *connection, { if ( (connection->write_buffer_append_offset != connection->write_buffer_send_offset) || - (connection->sk_cork_on) ) + /* if we expected to turn cork off, and it is still on, + we are not finished sending (can happen with gnutls_record_uncork) */ + ( (connection->sk_cork_on) && + (MHD_CONNECTION_HEADERS_SENDING != connection->state) ) ) return MHD_NO; connection->write_buffer_append_offset = 0; connection->write_buffer_send_offset = 0; @@ -2555,7 +2558,8 @@ process_broken_line (struct MHD_Connection *connection, adjacency); also, in the case where these are not adjacent (not sure how it can happen!), we would want to allocate from the end of the pool, so as to not destroy the read-buffer's - ability to grow nicely. */last = MHD_pool_reallocate (connection->pool, + ability to grow nicely. */// + last = MHD_pool_reallocate (connection->pool, last, last_len + 1, last_len + tmp_len + 1); diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c index f366ef67..339dad2b 100644 --- a/src/microhttpd/mhd_send.c +++ b/src/microhttpd/mhd_send.c @@ -330,6 +330,7 @@ MHD_send_on_connection_ (struct MHD_Connection *connection, buffer, buffer_size, MAYBE_MSG_NOSIGNAL | (want_cork ? MSG_MORE : 0)); + connection->sk_cork_on = want_cork; /* pretend corking happened as requested */ #else ret = send (connection->socket_fd, buffer, diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c index 9a21925a..27386046 100644 --- a/src/microhttpd/response.c +++ b/src/microhttpd/response.c @@ -904,7 +904,7 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh, else #endif { - if (0 == + if (0 != MHD_socket_cork_ (connection->socket_fd, true)) { @@ -930,7 +930,9 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh, else #endif { - if (0 == + if (! connection->sk_cork_on) + return MHD_YES; + if (0 != MHD_socket_cork_ (connection->socket_fd, false)) {