From 9c1546ccfd3767b096818d8928e61113c79d7cac Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 2 Feb 2022 00:13:31 -0500 Subject: [PATCH] fix: correct timeout bug again --- CHANGELOG.md | 6 +++++- Gemfile.lock | 2 +- lib/jekyll-indico/core.rb | 6 ++++-- lib/jekyll-indico/version.rb | 2 +- spec/jekyll-indico_spec.rb | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7e01fc..e69b7da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,14 @@ +# Version 0.4.5 + +Fix timeout being incorrectly called again. + # Version 0.4.4 Fix timeout being incorrectly called. # Version 0.4.3 -Fix warning message for classic tokens. Add time prinout to help judge need for +Fix warning message for classic tokens. Add time printout to help judge need for timeout setting. # Version 0.4.2 diff --git a/Gemfile.lock b/Gemfile.lock index ce6a4cd..b9a9406 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - jekyll-indico (0.4.4) + jekyll-indico (0.4.5) jekyll (>= 3.8, < 5.0) GEM diff --git a/lib/jekyll-indico/core.rb b/lib/jekyll-indico/core.rb index a9ec728..5e8e769 100644 --- a/lib/jekyll-indico/core.rb +++ b/lib/jekyll-indico/core.rb @@ -69,14 +69,16 @@ def download_and_iterate(base_url, indico_id, timeout: nil, **params, &block) uri.query = URI.encode_www_form(params) req = Net::HTTP::Get.new(uri) - req.read_timeout = timeout if timeout if ENV['INDICO_TOKEN'] req['Authorization'] = "Bearer #{ENV['INDICO_TOKEN']}" elsif ENV['INDICO_SECRET_KEY'] || ENV['INDICO_API_KEY'] raise Error, 'Use INDICO_TOKEN with a new-style token' end - response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) } + opts = { use_ssl: true } + opts[:read_timeout] = timeout if timeout + + response = Net::HTTP.start(uri.hostname, uri.port, **opts) { |http| http.request(req) } string = response.body parsed = JSON.parse(string) # returns a hash diff --git a/lib/jekyll-indico/version.rb b/lib/jekyll-indico/version.rb index c7bd142..e037e7c 100644 --- a/lib/jekyll-indico/version.rb +++ b/lib/jekyll-indico/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module JekyllIndico - VERSION = '0.4.4' + VERSION = '0.4.5' end diff --git a/spec/jekyll-indico_spec.rb b/spec/jekyll-indico_spec.rb index 2729497..c76e3cb 100644 --- a/spec/jekyll-indico_spec.rb +++ b/spec/jekyll-indico_spec.rb @@ -9,7 +9,7 @@ context 'with a CERN topical meeting' do before :all do - @meeting = JekyllIndico::Meetings.new('https://indico.cern.ch', 10570) + @meeting = JekyllIndico::Meetings.new('https://indico.cern.ch', 10570, timeout: 120) end it 'has expected meetings' do