Compare commits

..

No commits in common. "7ed7eec2dc9f40945651fa3ac06452e44d271aaf" and "325f7141c846f95b2d4ee773d5a91cdf76b10abf" have entirely different histories.

8 changed files with 10 additions and 40 deletions

View File

@ -17,7 +17,7 @@ group :test do
gem "minitest-proveit"
gem "ruby-ntlm"
gem "sentry-ruby" if RUBY_VERSION >= "2.4.0"
gem "spy", "< 1.0.4" # TODO: remove this once upstream fixes bug
gem "spy"
if RUBY_VERSION < "2.3.0"
gem "webmock", "< 3.15.0"
else

View File

@ -1,13 +0,0 @@
# 0.22.0
## Improvements
### Happy Eyeballs v2 finalized
Until now, httpx was issuing concurrent DNS requests, but it'd only start connecting to the first, and then on the following by the right order, but sequentially.
`httpx` will now establish connections concurrently to both IPv6 and IPv4 addresses of a given domain; the first one to succeed terminates the other. Successful connection means completion of both TCP and TLS (when applicable) handshakes.
### HTTPX::Response::Body#encoding
A new method, `#encoding`, can be called on response bodies. It'll return the encoding of the response payload.

View File

@ -76,13 +76,6 @@ module HTTPX
self.addresses = @options.addresses if @options.addresses
end
def clone_new_connection
new_conn = self.class.new(@type, @origin, @options)
once(:open, &new_conn.method(:reset))
new_conn.once(:open, &method(:close))
new_conn
end
# this is a semi-private method, to be used by the resolver
# to initiate the io object.
def addresses=(addrs)

View File

@ -129,7 +129,6 @@ module HTTPX
end
def on_resolver_connection(connection)
@connections << connection unless @connections.include?(connection)
found_connection = @connections.find do |ch|
ch != connection && ch.mergeable?(connection)
end

View File

@ -69,8 +69,7 @@ module HTTPX
@building_connection = true
connection = @options.connection_class.new("ssl", @uri, @options.merge(ssl: { alpn_protocols: %w[h2] }))
@pool.init_connection(connection, @options)
# only explicity emit addresses if connection didn't pre-resolve, i.e. it's not an IP.
emit_addresses(connection, @family, @uri_addresses) unless connection.addresses
emit_addresses(connection, @family, @uri_addresses)
@building_connection = false
connection
end

View File

@ -63,26 +63,20 @@ module HTTPX
log { "resolver: A response, applying resolution delay..." }
@pool.after(0.05) do
# double emission check
emit_resolved_connection(connection, addresses) unless connection.addresses && addresses.intersect?(connection.addresses)
unless connection.addresses && addresses.intersect?(connection.addresses)
connection.addresses = addresses
emit(:resolve, connection)
end
end
else
emit_resolved_connection(connection, addresses)
connection.addresses = addresses
emit(:resolve, connection)
end
end
private
def emit_resolved_connection(connection, addresses)
if connection.io && connection.connecting? && @pool
new_connection = connection.clone_new_connection
@pool.init_connection(new_connection, connection.options)
connection = new_connection
end
connection.addresses = addresses
emit(:resolve, connection)
end
def early_resolve(connection, hostname: connection.origin.host)
addresses = @resolver_options[:cache] && (connection.addresses || HTTPX::Resolver.nolookup_resolve(hostname))

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
module HTTPX
VERSION = "0.22.0"
VERSION = "0.21.1"
end

View File

@ -36,8 +36,6 @@ module HTTPX
@keep_alive_timeout: Numeric?
@total_timeout: Numeric?
def clone_new_connection: () -> instance
def addresses: () -> Array[ipaddr]?
def addresses=: (Array[ipaddr]) -> void