瀏覽代碼

Use SSL_ERROR_ZERO_RETURN to check if the SSL peer is closed.

yhirose 2 年之前
父節點
當前提交
1ebb8412c5
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      httplib.h

+ 2 - 1
httplib.h

@@ -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;
     }