mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-11 00:01:38 -04:00
setting the connect timeout port as envvar
This commit is contained in:
parent
dc6b3a6827
commit
e4e04e9fe8
@ -58,7 +58,7 @@ class SessionTest < Minitest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_session_timeout_connect_timeout
|
def test_session_timeout_connect_timeout
|
||||||
uri = build_uri("/", origin("127.0.0.1:9090"))
|
uri = build_uri("/", origin("127.0.0.1:#{CONNECT_TIMEOUT_PORT}"))
|
||||||
session = HTTPX.timeout(connect_timeout: 0.5, operation_timeout: 30, total_timeout: 2)
|
session = HTTPX.timeout(connect_timeout: 0.5, operation_timeout: 30, total_timeout: 2)
|
||||||
response = session.get(uri)
|
response = session.get(uri)
|
||||||
assert response.is_a?(HTTPX::ErrorResponse), "response should have failed (#{response.class})"
|
assert response.is_a?(HTTPX::ErrorResponse), "response should have failed (#{response.class})"
|
||||||
|
@ -11,8 +11,10 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# use port 9090 to test connection timeouts
|
# use port 9090 to test connection timeouts
|
||||||
iptables -A OUTPUT -p tcp -m tcp --tcp-flags SYN SYN --sport 9090 -j DROP
|
CONNECT_TIMEOUT_PORT=9090
|
||||||
|
iptables -A OUTPUT -p tcp -m tcp --tcp-flags SYN SYN --sport $CONNECT_TIMEOUT_PORT -j DROP
|
||||||
|
|
||||||
|
export CONNECT_TIMEOUT_PORT=$CONNECT_TIMEOUT_PORT
|
||||||
export PATH=$GEM_HOME/bin:$BUNDLE_PATH/gems/bin:$PATH
|
export PATH=$GEM_HOME/bin:$BUNDLE_PATH/gems/bin:$PATH
|
||||||
mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
|
mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
|
||||||
gem install bundler -v="1.17.3" --no-doc --conservative
|
gem install bundler -v="1.17.3" --no-doc --conservative
|
||||||
|
@ -22,7 +22,9 @@ Dir[File.join(".", "test", "support", "**", "*.rb")].sort.each { |f| require f }
|
|||||||
OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE.add_file(ENV["SSL_CERT_FILE"]) if RUBY_VERSION.start_with?("2.3") && ENV.key?("SSL_CERT_FILE")
|
OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE.add_file(ENV["SSL_CERT_FILE"]) if RUBY_VERSION.start_with?("2.3") && ENV.key?("SSL_CERT_FILE")
|
||||||
|
|
||||||
# 9090 drops SYN packets for connect timeout tests, make sure there's a server binding there.
|
# 9090 drops SYN packets for connect timeout tests, make sure there's a server binding there.
|
||||||
server = TCPServer.new("127.0.0.1", 9090)
|
CONNECT_TIMEOUT_PORT = ENV.fetch("CONNECT_TIMEOUT_PORT", 9090).to_i
|
||||||
|
|
||||||
|
server = TCPServer.new("127.0.0.1", CONNECT_TIMEOUT_PORT)
|
||||||
|
|
||||||
Thread.start do
|
Thread.start do
|
||||||
begin
|
begin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user