diff --git a/lib/webrick/httpserver.rb b/lib/webrick/httpserver.rb index 0d261bf0..bbb98c09 100644 --- a/lib/webrick/httpserver.rb +++ b/lib/webrick/httpserver.rb @@ -74,6 +74,11 @@ def run(sock) begin timeout = @config[:RequestTimeout] while timeout > 0 + # at this point, the client may have already sent data which was + # read by the socket, but openssl may have already buffered it. + # This happens way more in JRuby due to JVM thread scheduling. + break if sock.respond_to?(:pending) && sock.pending > 0 + break if sock.to_io.wait_readable(0.5) break if @status != :Running timeout -= 0.5