client fallsback back on an error response if a timeout has been achieved, this way enabling to return successful responses

This commit is contained in:
HoneyryderChuck 2018-01-13 15:43:21 +00:00
parent 65722a3b12
commit 167970cb65

View File

@ -85,12 +85,20 @@ module HTTPX
# guarantee ordered responses
loop do
request = requests.shift
@connection.next_tick until response = fetch_response(request)
begin
request = requests.first
@connection.next_tick until response = fetch_response(request)
responses << response
responses << response
requests.shift
break if requests.empty?
break if requests.empty?
rescue TimeoutError => e
while requests.shift
responses << ErrorResponse.new(e.message, 0)
end
break
end
end
requests.size == 1 ? responses.first : responses
end