mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
testing connection timeout errors
This commit is contained in:
parent
6005165271
commit
21e5aa8f35
@ -358,9 +358,11 @@ module HTTPX
|
||||
end
|
||||
|
||||
def handle_error(error)
|
||||
if error.instance_of?(TimeoutError) && @timeout
|
||||
@timeout -= error.timeout
|
||||
return unless @timeout <= 0
|
||||
if error.instance_of?(TimeoutError)
|
||||
if @timeout
|
||||
@timeout -= error.timeout
|
||||
return unless @timeout <= 0
|
||||
end
|
||||
|
||||
error = error.to_connection_error if connecting?
|
||||
end
|
||||
|
@ -18,12 +18,13 @@ module Requests
|
||||
assert response.status =~ /timed out after \d+ seconds/i, "response should have timed out"
|
||||
end
|
||||
|
||||
# def test_http_timeout_connect_timeout
|
||||
# uri = build_uri("/delay/3")
|
||||
# session = HTTPX.timeout(connect_timeout: 0.5, operation_timeout: 30, total_timeout: 2)
|
||||
# response = session.get(uri)
|
||||
# assert response.is_a?(HTTPX::ErrorResponse), "response should have failed"
|
||||
# assert response.error.is_a?(HTTPX::ConnectTimeoutError), "response should have failed on connection"
|
||||
# end
|
||||
def test_http_timeout_connect_timeout
|
||||
uri = "#{origin("nghttp2.org")}:81"
|
||||
session = HTTPX.timeout(connect_timeout: 0.5, operation_timeout: 30, total_timeout: 10)
|
||||
response = session.get(uri)
|
||||
assert response.is_a?(HTTPX::ErrorResponse), "response should have failed (#{response.class})"
|
||||
assert response.error.is_a?(HTTPX::ConnectTimeoutError),
|
||||
"response should have failed on connection (#{response.error.class}: #{response.error})"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user