Skip to content

Commit

Permalink
fix: correct timeout bug again
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Feb 2, 2022
1 parent c23c5c4 commit 9c1546c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
jekyll-indico (0.4.4)
jekyll-indico (0.4.5)
jekyll (>= 3.8, < 5.0)

GEM
Expand Down
6 changes: 4 additions & 2 deletions lib/jekyll-indico/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll-indico/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module JekyllIndico
VERSION = '0.4.4'
VERSION = '0.4.5'
end
2 changes: 1 addition & 1 deletion spec/jekyll-indico_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9c1546c

Please sign in to comment.