mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
http1: added #consume; also, handling better 'connection: close' : if there were requests in-flight, assume that pipeline failed, and cap the concurrent number of requests to 1; this will disable pipelining, although the keep-alive header will still be sent
This commit is contained in:
parent
031d25fd02
commit
662be789ff
@ -82,9 +82,23 @@ module HTTPX
|
||||
emit(:response, request, response)
|
||||
|
||||
send(@pending.shift) unless @pending.empty?
|
||||
return unless response.headers["connection"] == "close"
|
||||
log { "connection closed" }
|
||||
emit(:close)
|
||||
if response.headers["connection"] == "close"
|
||||
unless @requests.empty?
|
||||
@requests.map { |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
|
||||
end
|
||||
log { "connection: close" }
|
||||
emit(:close)
|
||||
end
|
||||
end
|
||||
|
||||
def consume
|
||||
@requests.each do |request|
|
||||
handle(request)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
Loading…
x
Reference in New Issue
Block a user