Skip to content

Commit

Permalink
Merge pull request #260 from httprb/zanker/timeouts-are-sadness
Browse files Browse the repository at this point in the history
Fixed global timeout state persistence
  • Loading branch information
tarcieri committed Sep 29, 2015
2 parents ca6513a + 58ece86 commit 1a1c01b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/http/timeout/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ class Global < PerOperation

def initialize(*args)
super
reset_counter
end

# To future me: Don't remove this again, past you was smarter.
def reset_counter
@time_left = connect_timeout + read_timeout + write_timeout
@total_timeout = time_left
end
Expand Down
7 changes: 5 additions & 2 deletions spec/lib/http/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,19 @@ def simple_response(body, status = 200)
end

include_context "HTTP handling" do
let(:extra_options) { {} }
let(:options) { {} }
let(:server) { dummy }
let(:client) { described_class.new(options) }
let(:client) { described_class.new(options.merge(extra_options)) }
end

describe "working with SSL" do
run_server(:dummy_ssl) { DummyServer.new(:ssl => true) }

let(:extra_options) { {} }

let(:client) do
described_class.new options.merge :ssl_context => SSLHelper.client_context
described_class.new options.merge(:ssl_context => SSLHelper.client_context).merge(extra_options)
end

include_context "HTTP handling" do
Expand Down
4 changes: 2 additions & 2 deletions spec/support/http_handling_shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
end

context "it resets state when reusing connections" do
let(:options) { {:persistent => server.endpoint} }
let(:extra_options) { {:persistent => server.endpoint} }

let(:read_timeout) { 3 }
let(:read_timeout) { 2.5 }

it "does not timeout" do
client.get("#{server.endpoint}/sleep").body.to_s
Expand Down

0 comments on commit 1a1c01b

Please sign in to comment.