diff --git a/lib/http/timeout/null.rb b/lib/http/timeout/null.rb index 8d798807..cf2d3f0d 100644 --- a/lib/http/timeout/null.rb +++ b/lib/http/timeout/null.rb @@ -55,19 +55,19 @@ def write(data) private # Retry reading - def rescue_readable + def rescue_readable(timeout = read_timeout) yield rescue IO::WaitReadable - retry if @socket.to_io.wait_readable(read_timeout) - raise TimeoutError, "Read timed out after #{read_timeout} seconds" + retry if @socket.to_io.wait_readable(timeout) + raise TimeoutError, "Read timed out after #{timeout} seconds" end # Retry writing - def rescue_writable + def rescue_writable(timeout = write_timeout) yield rescue IO::WaitWritable - retry if @socket.to_io.wait_writable(write_timeout) - raise TimeoutError, "Write timed out after #{write_timeout} seconds" + retry if @socket.to_io.wait_writable(timeout) + raise TimeoutError, "Write timed out after #{timeout} seconds" end end end diff --git a/lib/http/timeout/per_operation.rb b/lib/http/timeout/per_operation.rb index 0c277fe1..1239f265 100644 --- a/lib/http/timeout/per_operation.rb +++ b/lib/http/timeout/per_operation.rb @@ -28,8 +28,8 @@ def connect(socket_class, host, port, nodelay = false) end def connect_ssl - rescue_readable do - rescue_writable do + rescue_readable(@connect_timeout) do + rescue_writable(@connect_timeout) do @socket.connect_nonblock end end