summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/pure/net.nim2
-rw-r--r--tests/stdlib/thttpclient.nim12
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/pure/net.nim b/lib/pure/net.nim
index fc04ef1af..ce769cb6a 100644
--- a/lib/pure/net.nim
+++ b/lib/pure/net.nim
@@ -1148,7 +1148,7 @@ proc waitFor(socket: Socket, waited: var float, timeout, size: int,
           return 1
         let sslPending = SSLPending(socket.sslHandle)
         if sslPending != 0:
-          return sslPending
+          return min(sslPending, size)
 
     var startTime = epochTime()
     let selRet = select(socket, timeout - int(waited * 1000.0))
diff --git a/tests/stdlib/thttpclient.nim b/tests/stdlib/thttpclient.nim
index fff02722a..c28f09100 100644
--- a/tests/stdlib/thttpclient.nim
+++ b/tests/stdlib/thttpclient.nim
@@ -154,8 +154,20 @@ proc ipv6Test() =
   serverFd.closeSocket()
   client.close()
 
+proc longTimeoutTest() =
+# Issue #2753
+  try:
+    var client = newHttpClient(timeout = 1000)
+    var resp = client.request("https://au.yahoo.com")
+    client.close()
+  except AssertionError:
+    doAssert false, "Exceptions should not be raised"
+  except:
+    discard
+
 syncTest()
 waitFor(asyncTest())
 ipv6Test()
+longTimeoutTest()
 
 echo "OK"