mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-12 00:01:58 -04:00
allowing to extend http2 channel for proxies; simplified proxy argument (uri instead of proxy_uri)
This commit is contained in:
parent
6f2d4c1540
commit
128b5fc97e
@ -88,6 +88,14 @@ module HTTPX
|
||||
|
||||
private
|
||||
|
||||
def headline_uri(request)
|
||||
request.path
|
||||
end
|
||||
|
||||
def set_request_headers(request)
|
||||
|
||||
end
|
||||
|
||||
def handle(request, stream)
|
||||
catch(:buffer_full) do
|
||||
request.transition(:headers)
|
||||
@ -110,10 +118,11 @@ module HTTPX
|
||||
end
|
||||
|
||||
def join_headers(stream, request)
|
||||
set_request_headers(request)
|
||||
headers = {}
|
||||
headers[":scheme"] = request.scheme
|
||||
headers[":method"] = request.verb.to_s.upcase
|
||||
headers[":path"] = request.path
|
||||
headers[":path"] = headline_uri(request)
|
||||
headers[":authority"] = request.authority
|
||||
headers = headers.merge(request.headers)
|
||||
log(stream.id) do
|
||||
|
@ -12,8 +12,8 @@ module HTTPX
|
||||
class Parameters
|
||||
attr_reader :uri
|
||||
|
||||
def initialize(proxy_uri: , username: nil, password: nil)
|
||||
@uri = proxy_uri.is_a?(URI::Generic) ? proxy_uri : URI(proxy_uri)
|
||||
def initialize(uri: , username: nil, password: nil)
|
||||
@uri = uri.is_a?(URI::Generic) ? uri : URI(uri)
|
||||
@username = username || @uri.user
|
||||
@password = password || @uri.password
|
||||
end
|
||||
@ -43,7 +43,7 @@ module HTTPX
|
||||
return @options.proxy if @options.proxy
|
||||
uri = URI(uri).find_proxy
|
||||
return unless uri
|
||||
{ proxy_uri: uri }
|
||||
{ uri: uri }
|
||||
end
|
||||
|
||||
def build_proxy_channel(proxy)
|
||||
|
@ -5,15 +5,15 @@ module Requests
|
||||
module Proxy
|
||||
# https://www.sslproxies.org
|
||||
PROXIES = %W[
|
||||
139.162.90.230:51089
|
||||
139.162.113.44:51089
|
||||
139.162.111.253:51089
|
||||
139.162.76.78:51089
|
||||
139.162.116.181:51089
|
||||
18.216.86.189:3128
|
||||
151.80.140.233:54566
|
||||
45.6.216.66:3128
|
||||
137.74.168.174:8080
|
||||
154.66.122.130:53281
|
||||
]
|
||||
|
||||
def test_plugin_proxy_anonymous
|
||||
client = HTTPX.plugin(:proxy).with_proxy(proxy_uri: proxy_uri)
|
||||
client = HTTPX.plugin(:proxy).with_proxy(uri: proxy_uri)
|
||||
uri = build_uri("/get")
|
||||
response = client.get(uri)
|
||||
verify_status(response.status, 200)
|
||||
|
Loading…
x
Reference in New Issue
Block a user