Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/http/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class StateError < ResponseError; end
# Generic Timeout error
class TimeoutError < Error; end

# Timeout when first establishing the conncetion
class ConnectTimeoutError < TimeoutError; end

# Header value is of unexpected format (similar to Net::HTTPHeaderSyntaxError)
class HeaderError < Error; end
end
2 changes: 1 addition & 1 deletion lib/http/timeout/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def reset_counter

def connect(socket_class, host, port, nodelay = false)
reset_timer
::Timeout.timeout(@time_left, TimeoutError) do
::Timeout.timeout(@time_left, ConnectTimeoutError) do
@socket = socket_class.open(host, port)
@socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) if nodelay
end
Expand Down
2 changes: 1 addition & 1 deletion lib/http/timeout/per_operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(*args)
end

def connect(socket_class, host, port, nodelay = false)
::Timeout.timeout(@connect_timeout, TimeoutError) do
::Timeout.timeout(@connect_timeout, ConnectTimeoutError) do
@socket = socket_class.open(host, port)
@socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) if nodelay
end
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/http/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ def on_error(request, error)
client.use(:test_feature => feature_instance).
timeout(0.001).
request(:post, sleep_url)
end.to raise_error(HTTP::TimeoutError)
expect(feature_instance.captured_error).to be_a(HTTP::TimeoutError)
end.to raise_error(HTTP::ConnectTimeoutError)
expect(feature_instance.captured_error).to be_a(HTTP::ConnectTimeoutError)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/http_handling_shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
sleep 1.25
end

expect { response }.to raise_error(HTTP::TimeoutError, /execution/)
expect { response }.to raise_error(HTTP::ConnectTimeoutError, /execution/)
end

it "errors if reading takes too long" do
Expand Down