lib/httpx/plugins/proxy/http.rb in httpx-0.7.0 vs lib/httpx/plugins/proxy/http.rb in httpx-0.8.0

- old
+ new

@@ -5,10 +5,14 @@ module HTTPX module Plugins module Proxy module HTTP module ConnectionMethods + def connecting? + super || @state == :connecting || @state == :connected + end + private def transition(nextstate) return super unless @options.proxy && @options.proxy.uri.scheme == "http" @@ -32,11 +36,10 @@ @parser.close @parser = nil when :idle @parser = ProxyParser.new(@write_buffer, @options) set_parser_callbacks(@parser) - @parser.on(:close) { transition(:closing) } end end super end @@ -46,18 +49,19 @@ # all requests in the queue are not only ALL HTTPS, but they also share the certificate, # and therefore, will share the connection. # if req.uri.scheme == "https" connect_request = ConnectRequest.new(req.uri, @options) - + @inflight += 1 parser.send(connect_request) else transition(:connected) end end def __http_on_connect(_, response) + @inflight -= 1 if response.status == 200 req = @pending.first request_uri = req.uri @io = ProxySSL.new(@io, request_uri, @options) transition(:connected) @@ -65,9 +69,10 @@ else pending = @pending + @parser.pending while (req = pending.shift) req.emit(:response, response) end + reset end end end class ProxyParser < Connection::HTTP1