mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
moved the matching logic of channel to its class, where it belongs
This commit is contained in:
parent
8006f5c8bc
commit
36480b8fbf
@ -35,23 +35,19 @@ module HTTPX
|
||||
@on_response = on_response
|
||||
end
|
||||
|
||||
def match?(uri)
|
||||
ip = TCPSocket.getaddress(uri.host)
|
||||
|
||||
ip == @io.ip &&
|
||||
uri.port == @io.port &&
|
||||
uri.scheme == @uri.scheme
|
||||
end
|
||||
|
||||
def to_io
|
||||
connect
|
||||
@io.to_io
|
||||
end
|
||||
|
||||
def uri
|
||||
@io.uri
|
||||
end
|
||||
|
||||
def remote_ip
|
||||
@io.ip
|
||||
end
|
||||
|
||||
def remote_port
|
||||
@io.port
|
||||
end
|
||||
|
||||
def close(hard=false)
|
||||
if pr = @parser
|
||||
pr.close
|
||||
|
@ -70,11 +70,8 @@ module HTTPX
|
||||
#
|
||||
def bind(uri)
|
||||
uri = URI(uri)
|
||||
ip = TCPSocket.getaddress(uri.host)
|
||||
return @channels.find do |channel|
|
||||
ip == channel.remote_ip &&
|
||||
uri.port == channel.remote_port &&
|
||||
uri.scheme == channel.uri.scheme
|
||||
channel.match?(uri)
|
||||
end || begin
|
||||
build_channel(uri)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user