Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Net::HTTP#read_timeout=

(::Float | ::Integer read_timeout) -> (::Float | ::Integer)
read_timeout=(sec)

Sets the read timeout, in seconds, for self to integer sec; the initial value is 60.

Argument sec must be a non-negative numeric value:

Example
http = Net::HTTP.new(hostname)
http.read_timeout # => 60
http.get('/todos/1') # => #<Net::HTTPOK 200 OK readbody=true>
http.read_timeout = 0
http.get('/todos/1') # Raises Net::ReadTimeout.
See also #put #request #proxy_user #request_get also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0