Skip to content
Ben Ubois edited this page Nov 1, 2018 · 9 revisions

By default, the HTTP gem does not enforce timeout on a request. You can enable per operation timeouts (each read/write/connect call) or global timeouts (sum of all read/write/connect calls) by configuring them through the chaining API.

Per operation timeouts are what Net::HTTP and the majority of HTTP clients do:

HTTP.timeout(connect: 5, write: 2, read: 10).get "http://example.com"

Global timeouts let you set an upper bound of how long a request can take, without having to rely on Timeout.timeout:

HTTP.timeout(3).get "http://example.com"

Uses a timeout of 3 seconds, for the entire get call.