mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
using the new uri method at the appropriate places; adding some logging when resolving, to correctly identify when translation of IDN hostname happens
This commit is contained in:
parent
f9c1d7de44
commit
50b65200ed
@ -51,7 +51,7 @@ module HTTPX
|
||||
def initialize(type, uri, options)
|
||||
@type = type
|
||||
@origins = [uri.origin]
|
||||
@origin = URI(uri.origin)
|
||||
@origin = Utils.uri(uri.origin)
|
||||
@options = Options.new(options)
|
||||
@window_size = @options.window_size
|
||||
@read_buffer = Buffer.new(BUFFER_SIZE)
|
||||
|
@ -43,7 +43,7 @@ module HTTPX
|
||||
|
||||
def initialize(verb, uri, options = {})
|
||||
@verb = verb.to_s.downcase.to_sym
|
||||
@uri = URI(uri)
|
||||
@uri = Utils.uri(uri)
|
||||
@options = Options.new(options)
|
||||
|
||||
raise(Error, "unknown method: #{verb}") unless METHODS.include?(@verb)
|
||||
|
@ -94,7 +94,14 @@ module HTTPX
|
||||
def resolve(connection = @connections.first, hostname = nil)
|
||||
return if @building_connection
|
||||
|
||||
hostname = hostname || @queries.key(connection) || connection.origin.host
|
||||
hostname ||= @queries.key(connection)
|
||||
|
||||
if hostname.nil?
|
||||
hostname = connection.origin.host
|
||||
if hostname != connection.origin.non_ascii_hostname
|
||||
log { "resolver: resolve IDN #{connection.origin.non_ascii_hostname} as #{hostname}" }
|
||||
end
|
||||
end
|
||||
type = @_record_types[hostname].first
|
||||
log { "resolver: query #{type} for #{hostname}" }
|
||||
begin
|
||||
|
@ -7,6 +7,7 @@ module HTTPX
|
||||
class Resolver::Native
|
||||
extend Forwardable
|
||||
include Resolver::ResolverMixin
|
||||
using URIExtensions
|
||||
|
||||
RESOLVE_TIMEOUT = 5
|
||||
RECORD_TYPES = {
|
||||
@ -237,7 +238,14 @@ module HTTPX
|
||||
raise Error, "no URI to resolve" unless connection
|
||||
return unless @write_buffer.empty?
|
||||
|
||||
hostname = hostname || @queries.key(connection) || connection.origin.host
|
||||
hostname ||= @queries.key(connection)
|
||||
|
||||
if hostname.nil?
|
||||
hostname = connection.origin.host
|
||||
if hostname != connection.origin.non_ascii_hostname
|
||||
log { "resolver: resolve IDN #{connection.origin.non_ascii_hostname} as #{hostname}" }
|
||||
end
|
||||
end
|
||||
@queries[hostname] = connection
|
||||
type = @_record_types[hostname].first
|
||||
log { "resolver: query #{type} for #{hostname}" }
|
||||
|
@ -66,7 +66,8 @@ module HTTPX
|
||||
end
|
||||
|
||||
def find_connection(request, connections, options)
|
||||
uri = URI(request.uri)
|
||||
uri = request.uri
|
||||
|
||||
connection = pool.find_connection(uri, options) || build_connection(uri, options)
|
||||
unless connections.nil? || connections.include?(connection)
|
||||
connections << connection
|
||||
|
Loading…
x
Reference in New Issue
Block a user