Skip to content

Commit 258992a

Browse files
committed
Changed to use non-blocking socket in is_ssl_peer_could_be_closed
1 parent a7bc00e commit 258992a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

httplib.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7418,6 +7418,10 @@ inline bool ClientImpl::send(Request &req, Response &res, Error &error) {
74187418

74197419
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
74207420
inline bool ClientImpl::is_ssl_peer_could_be_closed(SSL *ssl) const {
7421+
detail::set_nonblocking(socket_.sock, true);
7422+
auto se = detail::scope_exit(
7423+
[&]() { detail::set_nonblocking(socket_.sock, false); });
7424+
74217425
char buf[1];
74227426
return !SSL_peek(ssl, buf, 1) &&
74237427
SSL_get_error(ssl, 0) == SSL_ERROR_ZERO_RETURN;
@@ -7438,9 +7442,7 @@ inline bool ClientImpl::send_(Request &req, Response &res, Error &error) {
74387442

74397443
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
74407444
if (is_alive && is_ssl()) {
7441-
detail::set_nonblocking(socket_.sock, true);
74427445
if (is_ssl_peer_could_be_closed(socket_.ssl)) { is_alive = false; }
7443-
detail::set_nonblocking(socket_.sock, false);
74447446
}
74457447
#endif
74467448

0 commit comments

Comments
 (0)