Compare commits

..

No commits in common. "c99194e298c459a931672c550a27caf800bfb038" and "54480379127bac47480571004f67b5fc2383ca4c" have entirely different histories.

8 changed files with 26 additions and 36 deletions

View File

@ -30,7 +30,7 @@ variables:
.yjit_matrix: &yjit_matrix
parallel:
matrix:
- RUBYOPT: ["", "--yjit"]
- RUBYOPT: ["", "--jit --jit-warnings --jit-wait", "--yjit"]
# Cache gems in between builds
cache:
@ -81,14 +81,11 @@ test ruby 2/7:
./spec.sh ruby 2.7
test ruby 3/0:
<<: *test_settings
only:
- master
script:
./spec.sh ruby 3.0
test ruby 3/1:
<<: *test_settings
only:
- master
<<: *yjit_matrix
script:
./spec.sh ruby 3.1
test ruby 3/2:
@ -101,21 +98,6 @@ test truffleruby:
script:
./spec.sh truffleruby latest
allow_failure: true
regression tests:
image: "ruby:3.2"
variables:
BUNDLE_WITHOUT: assorted
CI: 1
COVERAGE_KEY: "$RUBY_ENGINE-$RUBY_VERSION-regression-tests"
artifacts:
paths:
- coverage/
stage: test
before_script:
- apt-get update && apt-get install -y libmagic-dev shared-mime-info
- bundle install
script:
- bundle exec rake regression_tests
coverage:
coverage: '/\(\d+.\d+\%\) covered/'

View File

@ -557,7 +557,7 @@ module HTTPX
return if @state == :closed
@io.connect
emit(:tcp_open, self) if @io.state == :connected
emit(:tcp_open) if @io.state == :connected
return unless @io.connected?

View File

@ -15,7 +15,7 @@ module HTTPX
# https://github.com/ruby/resolv/blob/095f1c003f6073730500f02acbdbc55f83d70987/lib/resolv.rb#L408
ip_address_families = begin
list = Socket.ip_address_list
if list.any? { |a| a.ipv6? && !a.ipv6_loopback? && !a.ipv6_linklocal? && !a.ipv6_unique_local? }
if list.any? { |a| a.ipv6? && !a.ipv6_loopback? && !a.ipv6_linklocal? }
[Socket::AF_INET6, Socket::AF_INET]
else
[Socket::AF_INET]

View File

@ -137,7 +137,7 @@ module HTTPX
new_connection = connection.class.new(connection.type, connection.origin, connection.options)
new_connection.family = family
connection.once(:tcp_open) { new_connection.force_reset }
connection.once(:tcp_open, &new_connection.method(:force_reset))
connection.once(:connect_error) do |err|
if new_connection.connecting?
new_connection.merge(connection)
@ -146,8 +146,8 @@ module HTTPX
end
end
new_connection.once(:tcp_open) do |new_conn|
new_conn.merge(connection)
new_connection.once(:tcp_open) do
new_connection.merge(connection)
connection.force_reset
end
new_connection.once(:connect_error) do |err|
@ -222,7 +222,6 @@ module HTTPX
def coalesce_connections(conn1, conn2)
return register_connection(conn2) unless conn1.coalescable?(conn2)
conn2.emit(:tcp_open, conn1)
conn1.merge(conn2)
@connections.delete(conn2)
end

View File

@ -54,7 +54,7 @@ module HTTPX
# double emission check
return if connection.addresses && !addresses.intersect?(connection.addresses)
log { "resolver: answer #{FAMILY_TYPES[RECORD_TYPES[family]]} #{connection.origin.host}: #{addresses.inspect}" }
log { "resolver: answer #{connection.origin.host}: #{addresses.inspect}" }
if @pool && # if triggered by early resolve, pool may not be here yet
!connection.io &&
connection.options.ip_families.size > 1 &&

View File

@ -8,7 +8,7 @@ class Bug_0_18_2_Test < Minitest::Test
include HTTPHelpers
def test_no_loop_forever_when_total_timeout_on_persistent
session = HTTPX.plugin(:persistent).with_timeout(total_timeout: 5)
session = HTTPX.plugin(:persistent).with_timeout(total_timeout: 1)
response1 = session.get("https://#{httpbin}/get")
sleep 2

View File

@ -9,8 +9,8 @@ class Bug_0_22_2_Test < Minitest::Test
Plugin = Module.new do
@connections = []
class << self
attr_reader :connections
def self.connections
@connections
end
self::ConnectionMethods = Module.new do
@ -22,12 +22,11 @@ class Bug_0_22_2_Test < Minitest::Test
end
def test_happy_eyeballs_v2_use_correct_family
ipv4_host = "badipv6.test.ipv6friday.org"
ipv6_host = "badipv4.test.ipv6friday.org"
connections = []
HTTPX.plugin(Plugin).wrap do |http|
_response_ipv4 = http.get("http://#{ipv4_host}")
_response_ipv6 = http.get("http://#{ipv6_host}")
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}" }
@ -36,4 +35,14 @@ class Bug_0_22_2_Test < Minitest::Test
assert connection_ipv4.family == Socket::AF_INET
assert connection_ipv6.family == Socket::AF_INET6
end
end if HTTPX::Session.default_options.ip_families.size > 1
private
def ipv4_host
"badipv6.test.ipv6friday.org"
end
def ipv6_host
"badipv4.test.ipv6friday.org"
end
end

View File

@ -97,7 +97,7 @@ fi
if [[ ${RUBY_VERSION:0:3} = "3.2" ]] && [[ "$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
COVERAGE_KEY="$RUBY_ENGINE-$RUBY_VERSION-regression-tests" bundle exec rake regression_tests
# standalone tests
for f in standalone_tests/*_test.rb; do