diff --git a/httplib.h b/httplib.h index 42181dff..2e13e2dc 100644 --- a/httplib.h +++ b/httplib.h @@ -19160,8 +19160,12 @@ inline bool SSLServer::process_and_close_socket(socket_t sock) { auto cleanup = detail::scope_exit([&] { if (handshake_done) { shutdown(session, !websocket_upgraded && ret); } free_session(session); - detail::shutdown_socket(sock); - detail::close_socket(sock); + if (handshake_done) { + detail::drain_and_close_socket(sock); + } else { + detail::shutdown_socket(sock); + detail::close_socket(sock); + } }); // Perform TLS accept handshake with timeout