@@ -39,6 +39,10 @@ class ProxyAgent(_AgentBase):
39
39
reactor: twisted reactor to place outgoing
40
40
connections.
41
41
42
+ proxy_reactor: twisted reactor to use for connections to the proxy server
43
+ reactor might have some blacklisting applied (i.e. for DNS queries),
44
+ but we need unblocked access to the proxy.
45
+
42
46
contextFactory (IPolicyForHTTPS): A factory for TLS contexts, to control the
43
47
verification parameters of OpenSSL. The default is to use a
44
48
`BrowserLikePolicyForHTTPS`, so unless you have special
@@ -59,6 +63,7 @@ class ProxyAgent(_AgentBase):
59
63
def __init__ (
60
64
self ,
61
65
reactor ,
66
+ proxy_reactor = None ,
62
67
contextFactory = BrowserLikePolicyForHTTPS (),
63
68
connectTimeout = None ,
64
69
bindAddress = None ,
@@ -68,18 +73,23 @@ def __init__(
68
73
):
69
74
_AgentBase .__init__ (self , reactor , pool )
70
75
76
+ if proxy_reactor is None :
77
+ self .proxy_reactor = reactor
78
+ else :
79
+ self .proxy_reactor = proxy_reactor
80
+
71
81
self ._endpoint_kwargs = {}
72
82
if connectTimeout is not None :
73
83
self ._endpoint_kwargs ["timeout" ] = connectTimeout
74
84
if bindAddress is not None :
75
85
self ._endpoint_kwargs ["bindAddress" ] = bindAddress
76
86
77
87
self .http_proxy_endpoint = _http_proxy_endpoint (
78
- http_proxy , reactor , ** self ._endpoint_kwargs
88
+ http_proxy , self . proxy_reactor , ** self ._endpoint_kwargs
79
89
)
80
90
81
91
self .https_proxy_endpoint = _http_proxy_endpoint (
82
- https_proxy , reactor , ** self ._endpoint_kwargs
92
+ https_proxy , self . proxy_reactor , ** self ._endpoint_kwargs
83
93
)
84
94
85
95
self ._policy_for_https = contextFactory
@@ -137,7 +147,7 @@ def request(self, method, uri, headers=None, bodyProducer=None):
137
147
request_path = uri
138
148
elif parsed_uri .scheme == b"https" and self .https_proxy_endpoint :
139
149
endpoint = HTTPConnectProxyEndpoint (
140
- self ._reactor ,
150
+ self .proxy_reactor ,
141
151
self .https_proxy_endpoint ,
142
152
parsed_uri .host ,
143
153
parsed_uri .port ,
0 commit comments