proxy: add inflight bookkeeping for http proxy; close the connection if receiving connect request error

This commit is contained in:
HoneyryderChuck 2020-04-18 17:44:32 +01:00
parent 1b97001b5f
commit 9a66db3ab4
2 changed files with 5 additions and 1 deletions

View File

@ -215,6 +215,8 @@ module HTTPX
case nextstate
when :closing
# this is a hack so that we can use the super method
# and it'll thing that the current state is open
@state = :open if @state == :connecting
end
super

View File

@ -51,7 +51,7 @@ module HTTPX
#
if req.uri.scheme == "https"
connect_request = ConnectRequest.new(req.uri, @options)
@inflight += 1
parser.send(connect_request)
else
transition(:connected)
@ -59,6 +59,7 @@ module HTTPX
end
def __http_on_connect(_, response)
@inflight -= 1
if response.status == 200
req = @pending.first
request_uri = req.uri
@ -70,6 +71,7 @@ module HTTPX
while (req = pending.shift)
req.emit(:response, response)
end
reset
end
end
end