Skip to content

Commit

Permalink
Use SSL_ERROR_ZERO_RETURN to check if the SSL peer is closed.
Browse files Browse the repository at this point in the history
  • Loading branch information
yhirose committed Mar 7, 2023
1 parent 7b69999 commit 1ebb841
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -6765,7 +6765,8 @@ inline bool ClientImpl::process_request(Stream &strm, Request &req,
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
if (is_ssl()) {
char buf[1];
if (SSL_peek(socket_.ssl, buf, 1) == 0) {
if (SSL_peek(socket_.ssl, buf, 1) == 0 &&
SSL_get_error(socket_.ssl, 0) == SSL_ERROR_ZERO_RETURN) {
error = Error::SSLPeerCouldBeClosed_;
return false;
}
Expand Down

0 comments on commit 1ebb841

Please sign in to comment.