mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-07-14 00:00:49 -04:00
Compare commits
No commits in common. "54480379127bac47480571004f67b5fc2383ca4c" and "b1c59c45ebe3dd24b8192d85a08288e96ab04ced" have entirely different histories.
5448037912
...
b1c59c45eb
@ -160,6 +160,7 @@ module HTTPX
|
||||
module URIExtensions
|
||||
# uri 0.11 backport, ships with ruby 3.1
|
||||
refine URI::Generic do
|
||||
public :set_host
|
||||
|
||||
def non_ascii_hostname
|
||||
@non_ascii_hostname
|
||||
|
@ -6,10 +6,11 @@ module HTTPX
|
||||
class UDP
|
||||
include Loggable
|
||||
|
||||
def initialize(ip, port, options)
|
||||
@host = ip
|
||||
@port = port
|
||||
@io = UDPSocket.new(IPAddr.new(ip).family)
|
||||
def initialize(uri, _, options)
|
||||
ip = IPAddr.new(uri.host)
|
||||
@host = ip.to_s
|
||||
@port = uri.port
|
||||
@io = UDPSocket.new(ip.family)
|
||||
@options = options
|
||||
end
|
||||
|
||||
|
@ -132,7 +132,9 @@ module HTTPX
|
||||
def try_clone_connection(connection, family)
|
||||
connection.family ||= family
|
||||
|
||||
return connection if connection.family == family
|
||||
if connection.family == family
|
||||
return connection
|
||||
end
|
||||
|
||||
new_connection = connection.class.new(connection.type, connection.origin, connection.options)
|
||||
new_connection.family = family
|
||||
|
@ -21,7 +21,21 @@ module HTTPX
|
||||
packet_size: 512,
|
||||
timeouts: Resolver::RESOLVE_TIMEOUT,
|
||||
}
|
||||
end.freeze
|
||||
end
|
||||
|
||||
# nameservers for ipv6 are misconfigured in certain systems;
|
||||
# this can use an unexpected endless loop
|
||||
# https://gitlab.com/honeyryderchuck/httpx/issues/56
|
||||
DEFAULTS[:nameserver].select! do |nameserver|
|
||||
begin
|
||||
IPAddr.new(nameserver)
|
||||
true
|
||||
rescue IPAddr::InvalidAddressError
|
||||
false
|
||||
end
|
||||
end if DEFAULTS[:nameserver]
|
||||
|
||||
DEFAULTS.freeze
|
||||
|
||||
DNS_PORT = 53
|
||||
|
||||
@ -304,8 +318,13 @@ module HTTPX
|
||||
|
||||
ip, port = @nameserver[@ns_index]
|
||||
port ||= DNS_PORT
|
||||
log { "resolver: server: #{ip}:#{port}..." }
|
||||
@io = UDP.new(ip, port, @options)
|
||||
uri = URI::Generic.build(scheme: "udp", port: port)
|
||||
# uri.hostname = ip
|
||||
# link-local IPv6 address may have a zone identifier, but URI does not support that yet.
|
||||
uri.set_host(ip)
|
||||
type = IO.registry(uri.scheme)
|
||||
log { "resolver: server: #{uri}..." }
|
||||
@io = type.new(uri, [IPAddr.new(ip)], @options)
|
||||
end
|
||||
|
||||
def transition(nextstate)
|
||||
|
@ -1,48 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
require "support/http_helpers"
|
||||
require "support/minitest_extensions"
|
||||
|
||||
class Bug_0_22_2_Test < Minitest::Test
|
||||
include HTTPHelpers
|
||||
|
||||
Plugin = Module.new do
|
||||
@connections = []
|
||||
def self.connections
|
||||
@connections
|
||||
end
|
||||
|
||||
self::ConnectionMethods = Module.new do
|
||||
def initialize(*)
|
||||
super
|
||||
on(:tcp_open) { Plugin.connections << self }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_happy_eyeballs_v2_use_correct_family
|
||||
connections = []
|
||||
|
||||
HTTPX.plugin(Plugin).wrap do |http|
|
||||
response_ipv4 = http.get("http://#{ipv4_host}")
|
||||
response_ipv6 = http.get("http://#{ipv6_host}")
|
||||
end
|
||||
assert Plugin.connections.size == 2
|
||||
connection_ipv4 = Plugin.connections.find { |conn| conn.origin.to_s == "http://#{ipv4_host}" }
|
||||
connection_ipv6 = Plugin.connections.find { |conn| conn.origin.to_s == "http://#{ipv6_host}" }
|
||||
|
||||
assert connection_ipv4.family == Socket::AF_INET
|
||||
assert connection_ipv6.family == Socket::AF_INET6
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def ipv4_host
|
||||
"badipv6.test.ipv6friday.org"
|
||||
end
|
||||
|
||||
def ipv6_host
|
||||
"badipv4.test.ipv6friday.org"
|
||||
end
|
||||
end
|
@ -94,7 +94,7 @@ if [[ "$RUBY_ENGINE" = "ruby" ]]; then
|
||||
COVERAGE_KEY="$RUBY_ENGINE-$RUBY_VERSION-integration-tests" bundle exec rake integration_tests
|
||||
fi
|
||||
|
||||
if [[ ${RUBY_VERSION:0:3} = "3.2" ]] && [[ "$RUBY_ENGINE" = "ruby" ]]; then
|
||||
if [[ ${RUBY_VERSION:0:1} = "3" ]] && [[ "$RUBY_ENGINE" = "ruby" ]]; then
|
||||
# regression tests
|
||||
# Testing them only with main ruby
|
||||
COVERAGE_KEY="$RUBY_ENGINE-$RUBY_VERSION-regression-tests" bundle exec rake regression_tests
|
||||
|
Loading…
x
Reference in New Issue
Block a user