Index: libmicrohttpd-0.9.76/src/microhttpd/connection.c =================================================================== --- libmicrohttpd-0.9.76.orig/src/microhttpd/connection.c +++ libmicrohttpd-0.9.76/src/microhttpd/connection.c @@ -1612,8 +1612,6 @@ connection_maximize_write_buffer (struct return c->write_buffer_size - c->write_buffer_append_offset; } - -#if 0 /* disable unused function */ /** * Shrink connection write buffer to the size of unsent data. * @@ -1654,10 +1652,6 @@ connection_shrink_write_buffer (struct M c->write_buffer = new_buf; } - -#endif /* unused function */ - - /** * Switch connection from recv mode to send mode. * @@ -4700,6 +4694,8 @@ MHD_connection_handle_idle (struct MHD_C #ifdef UPGRADE_SUPPORT if (NULL != connection->response->upgrade_handler) { + connection_shrink_write_buffer(connection); + connection->state = MHD_CONNECTION_UPGRADE; /* This connection is "upgraded". Pass socket to application. */ if (MHD_NO ==