Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit 38153ea

Browse files
committed
Actually connect to proxy for integration tests
1 parent 88ee2f1 commit 38153ea

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

test/server.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _start_proxy(self):
116116

117117
# Once listen() returns, the server socket is ready
118118
rx_sock.listen(1)
119-
tx_sock.connect((host, port))
119+
tx_sock.connect((self.host, self.port))
120120

121121
self.socket_handler(tx_sock, rx_sock)
122122
sock.close()
@@ -161,7 +161,9 @@ def _start_server(self, socket_handler):
161161

162162
if self.proxy:
163163
self._start_proxy()
164+
164165
self.proxy_host = self.proxy_thread.proxy_host
166+
self.proxy_port = self.proxy_thread.proxy_port
165167

166168
def _start_proxy(self):
167169
"""
@@ -178,10 +180,17 @@ def _proxy_socket_handler(tx_sock, rx_sock):
178180
self.proxy_thread.start()
179181

180182
def get_connection(self):
183+
if not self.proxy:
184+
host = self.host
185+
port = self.port
186+
else:
187+
host = self.proxy_host
188+
port = self.proxy_port
189+
181190
if self.h2:
182-
return HTTP20Connection(self.host, self.port, self.secure)
191+
return HTTP20Connection(host, port, self.secure)
183192
else:
184-
return HTTP11Connection(self.host, self.port, self.secure)
193+
return HTTP11Connection(host, port, self.secure)
185194

186195
def get_encoder(self):
187196
"""
@@ -196,3 +205,6 @@ def tear_down(self):
196205
Tears down the testing thread.
197206
"""
198207
self.server_thread.join(0.1)
208+
209+
if self.proxy:
210+
self.proxy_thread.join(0.1)

0 commit comments

Comments
 (0)