relax icon indicating copy to clipboard operation
relax copied to clipboard

Net::HTTP's open_timeout is unsettable

Open nbibler opened this issue 12 years ago • 0 comments

The current implementation sets a default read_timeout on Net::HTTP to 60 seconds (per a constant). There is seemingly no trivial way to set the open_timeout, however.

From Faraday's Net::HTTP adapter:

req = env[:request]
http.read_timeout = http.open_timeout = req[:timeout] if req[:timeout]
http.open_timeout = req[:open_timeout]                if req[:open_timeout]

For the time being, I'm doing the following:

class MyRelaxResource
  def perform_thing
    response = post("/my/url") do |request|
      request.options.merge!(timeout: 5, open_timeout: 3)
    end
    MyResponse.new(response)
  end
end

nbibler avatar Jul 20 '12 17:07 nbibler