Avoid connection timeout of "inspec version" (#1538)

* Add open_timeout to NET::HTTP.start call
Signed-off-by: Makoto Nozaki <makoto.nozaki@twosigma.com>

* Code cleanup based on the discussion at #1538
Signed-off-by: Makoto Nozaki <makoto.nozaki@twosigma.com>
This commit is contained in:
Makoto Nozaki 2017-03-06 11:23:42 -05:00 committed by Adam Leff
parent 66dce387ee
commit f913b56ffc

View file

@ -8,8 +8,9 @@ class LatestInSpecVersion
# fetches the latest version from rubygems server
def latest
uri = URI('https://rubygems.org/api/v1/gems/inspec.json')
res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') {|http|
http.read_timeout = 0.5
res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https',
open_timeout: 0.5, read_timeout: 0.5
) {|http|
http.get(uri.path)
}
inspec_info = JSON.parse(res.body)