relax
relax copied to clipboard
Net::HTTP's open_timeout is unsettable
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