From f525ef6b0c1572d48bc72795f87fef8fb48378a5 Mon Sep 17 00:00:00 2001 From: Friedrich Raschwitz <119617043+dotconfig404@users.noreply.github.com> Date: Mon, 20 Oct 2025 15:05:19 +0200 Subject: [PATCH 1/2] preventing hang when io readable, but no app-data TCPSocket may be readable due to handshake data arriving (NewSessionTicket's may arrive unprompted) - this essentially calls a SSL_read to process handshake data and returns nil when an actual EOFError has been raised, otherwise just returns (probably the symbol :wait_readable) --- lib/net/http.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index f64f7ba..dedbd29 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -2462,10 +2462,13 @@ def begin_transport(req) debug 'Conn close because of keep_alive_timeout' @socket.close connect - elsif @socket.io.to_io.wait_readable(0) && @socket.eof? - debug "Conn close because of EOF" - @socket.close - connect + end + while @socket.io.to_io.wait_readable(0) + if @socket.io.to_io.read_nonblock(1, exception: false) == nil + debug "Conn close because of EOF" + @socket.close + connect + end end end From 2cdcab235e18a75d38b24fb98f20d8abc493aff0 Mon Sep 17 00:00:00 2001 From: Friedrich Raschwitz <119617043+dotconfig404@users.noreply.github.com> Date: Mon, 20 Oct 2025 20:35:03 +0200 Subject: [PATCH 2/2] fix typo: read_nonblock call on SSLSocket sorry, typo --- lib/net/http.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index dedbd29..47d510b 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -2464,7 +2464,7 @@ def begin_transport(req) connect end while @socket.io.to_io.wait_readable(0) - if @socket.io.to_io.read_nonblock(1, exception: false) == nil + if @socket.io.read_nonblock(1, exception: false) == nil debug "Conn close because of EOF" @socket.close connect