Skip to content

Commit 243e093

Browse files
committed
Resolve #2017
1 parent 8311e11 commit 243e093

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

httplib.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ struct Request {
628628
Ranges ranges;
629629
Match matches;
630630
std::unordered_map<std::string, std::string> path_params;
631+
std::function<bool()> is_connection_closed = []() { return true; };
631632

632633
// for client
633634
ResponseHandler response_handler;
@@ -7217,6 +7218,11 @@ Server::process_request(Stream &strm, const std::string &remote_addr,
72177218
}
72187219
}
72197220

7221+
// Setup `is_connection_closed` method
7222+
req.is_connection_closed = [&]() {
7223+
return !detail::is_socket_alive(strm.socket());
7224+
};
7225+
72207226
// Routing
72217227
auto routed = false;
72227228
#ifdef CPPHTTPLIB_NO_EXCEPTIONS

0 commit comments

Comments
 (0)