mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
guarding against pipelining errors on keep-alive connections, in which the first request will be received, but the second will timeout; in such cases, disable_pipelining and retry; only infer pipelining if at least 2 requests have been flushed in the buffer at the same time
This commit is contained in:
parent
083dd5ae6d
commit
91be043a52
@ -43,7 +43,10 @@ module HTTPX
|
||||
@pending << request
|
||||
return
|
||||
end
|
||||
@requests << request unless @requests.include?(request)
|
||||
unless @requests.include?(request)
|
||||
@requests << request
|
||||
@pipelining = true if @requests.size > 1
|
||||
end
|
||||
handle(request)
|
||||
end
|
||||
|
||||
@ -133,8 +136,14 @@ module HTTPX
|
||||
end
|
||||
|
||||
def handle_error(ex)
|
||||
@requests.each do |request|
|
||||
emit(:error, request, ex)
|
||||
if @pipelining
|
||||
disable_pipelining
|
||||
emit(:reset)
|
||||
throw(:called)
|
||||
else
|
||||
@requests.each do |request|
|
||||
emit(:error, request, ex)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -149,13 +158,14 @@ module HTTPX
|
||||
end
|
||||
end
|
||||
|
||||
def disable_concurrency
|
||||
def disable_pipelining
|
||||
return if @requests.empty?
|
||||
@requests.each { |r| r.transition(:idle) }
|
||||
# server doesn't handle pipelining, and probably
|
||||
# doesn't support keep-alive. Fallback to send only
|
||||
# 1 keep alive request.
|
||||
@max_concurrent_requests = 1
|
||||
@pipelining = false
|
||||
end
|
||||
|
||||
def set_request_headers(request)
|
||||
|
Loading…
x
Reference in New Issue
Block a user