mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
rewrite http proxy layer to accomodate https proxies
it should test both http ad https requests over an http proxy, and http and http2 requests over an https proxy
This commit is contained in:
parent
2f507915e4
commit
bbed0103e1
@ -18,14 +18,32 @@ module Requests
|
||||
end
|
||||
|
||||
def test_plugin_http_http_proxy
|
||||
return unless origin.start_with?("http://")
|
||||
HTTPX.plugin(SessionWithPool)
|
||||
.plugin(ProxyResponseDetector)
|
||||
.plugin(:proxy, fallback_protocol: "http/1.1")
|
||||
.with_proxy(uri: http_proxy).wrap do |session|
|
||||
uri = build_uri("/get")
|
||||
response = session.get(uri)
|
||||
verify_status(response, 200)
|
||||
verify_body_length(response)
|
||||
assert response.proxied?
|
||||
|
||||
session = HTTPX.plugin(:proxy, fallback_protocol: "http/1.1").plugin(ProxyResponseDetector).with_proxy(uri: http_proxy)
|
||||
uri = build_uri("/get")
|
||||
response = session.get(uri)
|
||||
verify_status(response, 200)
|
||||
verify_body_length(response)
|
||||
assert response.proxied?
|
||||
conn = session.pool.connections.first
|
||||
assert conn.io.is_a?(HTTPX::TCP)
|
||||
end
|
||||
end
|
||||
|
||||
def test_plugin_http_https_proxy
|
||||
HTTPX.plugin(SessionWithPool).plugin(ProxyResponseDetector).plugin(:proxy).with_proxy(uri: https_proxy).wrap do |session|
|
||||
uri = build_uri("/get")
|
||||
response = session.get(uri)
|
||||
verify_status(response, 200)
|
||||
verify_body_length(response)
|
||||
assert response.proxied?
|
||||
|
||||
conn = session.pool.connections.first
|
||||
assert conn.io.is_a?(HTTPX::SSL)
|
||||
end
|
||||
end
|
||||
|
||||
def test_plugin_http_no_proxy
|
||||
@ -59,16 +77,6 @@ module Requests
|
||||
assert response.proxied?
|
||||
end
|
||||
|
||||
def test_plugin_https_connect_http1_proxy
|
||||
# return unless origin.start_with?("https://")
|
||||
session = HTTPX.plugin(:proxy).plugin(ProxyResponseDetector).with_proxy(uri: http_proxy)
|
||||
uri = build_uri("/get")
|
||||
response = session.get(uri)
|
||||
verify_status(response, 200)
|
||||
verify_body_length(response)
|
||||
assert response.proxied?
|
||||
end
|
||||
|
||||
# TODO: uncomment when supporting H2 CONNECT
|
||||
# def test_plugin_https_connect_h2_proxy
|
||||
# return unless origin.start_with?("https://")
|
||||
|
Loading…
x
Reference in New Issue
Block a user