mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-12-10 00:03:00 -05:00
fixing overwriting connection #transition, which wasn't taking tcp connect on proxy errors
This commit is contained in:
parent
f3d50e6a06
commit
1343c74e31
@ -489,6 +489,18 @@ module HTTPX
|
|||||||
end
|
end
|
||||||
|
|
||||||
def transition(nextstate)
|
def transition(nextstate)
|
||||||
|
handle_transition(nextstate)
|
||||||
|
rescue Errno::ECONNREFUSED,
|
||||||
|
Errno::EADDRNOTAVAIL,
|
||||||
|
Errno::EHOSTUNREACH,
|
||||||
|
TLSError => e
|
||||||
|
# connect errors, exit gracefully
|
||||||
|
handle_error(e)
|
||||||
|
@state = :closed
|
||||||
|
emit(:close)
|
||||||
|
end
|
||||||
|
|
||||||
|
def handle_transition(nextstate)
|
||||||
case nextstate
|
case nextstate
|
||||||
when :idle
|
when :idle
|
||||||
@timeout = @current_timeout = @options.timeout[:connect_timeout]
|
@timeout = @current_timeout = @options.timeout[:connect_timeout]
|
||||||
@ -525,14 +537,6 @@ module HTTPX
|
|||||||
emit(:activate)
|
emit(:activate)
|
||||||
end
|
end
|
||||||
@state = nextstate
|
@state = nextstate
|
||||||
rescue Errno::ECONNREFUSED,
|
|
||||||
Errno::EADDRNOTAVAIL,
|
|
||||||
Errno::EHOSTUNREACH,
|
|
||||||
TLSError => e
|
|
||||||
# connect errors, exit gracefully
|
|
||||||
handle_error(e)
|
|
||||||
@state = :closed
|
|
||||||
emit(:close)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def purge_after_closed
|
def purge_after_closed
|
||||||
|
|||||||
@ -57,7 +57,9 @@ module HTTPX
|
|||||||
@io = build_socket
|
@io = build_socket
|
||||||
end
|
end
|
||||||
try_connect
|
try_connect
|
||||||
rescue Errno::EHOSTUNREACH => e
|
rescue Errno::ECONNREFUSED,
|
||||||
|
Errno::EADDRNOTAVAIL,
|
||||||
|
Errno::EHOSTUNREACH => e
|
||||||
raise e if @ip_index <= 0
|
raise e if @ip_index <= 0
|
||||||
|
|
||||||
@ip_index -= 1
|
@ip_index -= 1
|
||||||
|
|||||||
@ -81,7 +81,7 @@ module HTTPX
|
|||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def transition(nextstate)
|
def handle_transition(nextstate)
|
||||||
state = @state
|
state = @state
|
||||||
super
|
super
|
||||||
meter_elapsed_time("Connection##{object_id}[#{@origin}]: #{state} -> #{nextstate}") if nextstate == @state
|
meter_elapsed_time("Connection##{object_id}[#{@origin}]: #{state} -> #{nextstate}") if nextstate == @state
|
||||||
|
|||||||
@ -234,7 +234,7 @@ module HTTPX
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def transition(nextstate)
|
def handle_transition(nextstate)
|
||||||
return super unless @options.proxy
|
return super unless @options.proxy
|
||||||
|
|
||||||
case nextstate
|
case nextstate
|
||||||
|
|||||||
@ -13,7 +13,7 @@ module HTTPX
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def transition(nextstate)
|
def handle_transition(nextstate)
|
||||||
return super unless @options.proxy && @options.proxy.uri.scheme == "http"
|
return super unless @options.proxy && @options.proxy.uri.scheme == "http"
|
||||||
|
|
||||||
case nextstate
|
case nextstate
|
||||||
@ -54,7 +54,7 @@ module HTTPX
|
|||||||
@inflight += 1
|
@inflight += 1
|
||||||
parser.send(connect_request)
|
parser.send(connect_request)
|
||||||
else
|
else
|
||||||
transition(:connected)
|
handle_transition(:connected)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ module HTTPX
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def transition(nextstate)
|
def handle_transition(nextstate)
|
||||||
return super unless @options.proxy && PROTOCOLS.include?(@options.proxy.uri.scheme)
|
return super unless @options.proxy && PROTOCOLS.include?(@options.proxy.uri.scheme)
|
||||||
|
|
||||||
case nextstate
|
case nextstate
|
||||||
|
|||||||
@ -46,7 +46,7 @@ module HTTPX
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def transition(nextstate)
|
def handle_transition(nextstate)
|
||||||
return super unless @options.proxy && @options.proxy.uri.scheme == "socks5"
|
return super unless @options.proxy && @options.proxy.uri.scheme == "socks5"
|
||||||
|
|
||||||
case nextstate
|
case nextstate
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user