From 243e09319b1e97b60c5f771c4377435f105b9bef Mon Sep 17 00:00:00 2001 From: yhirose Date: Fri, 17 Jan 2025 14:28:55 -0500 Subject: [PATCH] Resolve #2017 --- httplib.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/httplib.h b/httplib.h index c5c8f3f..0ab8ac7 100644 --- a/httplib.h +++ b/httplib.h @@ -628,6 +628,7 @@ struct Request { Ranges ranges; Match matches; std::unordered_map path_params; + std::function is_connection_closed = []() { return true; }; // for client ResponseHandler response_handler; @@ -7217,6 +7218,11 @@ Server::process_request(Stream &strm, const std::string &remote_addr, } } + // Setup `is_connection_closed` method + req.is_connection_closed = [&]() { + return !detail::is_socket_alive(strm.socket()); + }; + // Routing auto routed = false; #ifdef CPPHTTPLIB_NO_EXCEPTIONS