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

Commit 2a460e2

Browse files
committed
Fix issues not on pull request with host and port not being set properly, SSL connections for proxy ignored for now
1 parent 6b3aa8e commit 2a460e2

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

hyper/http11/connection.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,16 @@ def connect(self):
107107
if self._sock is None:
108108
if not self.proxy_host:
109109
host = self.host
110+
port = self.port
110111
else:
112+
host = self.proxy_host
111113
port = self.proxy_host
112114

113115
sock = socket.create_connection((host, port), 5)
114116
proto = None
115117

116118
if self.secure:
119+
assert not self.proxy_host, "Using a proxy with HTTPS not yet supported."
117120
sock, proto = wrap_socket(sock, host, self.ssl_context)
118121

119122
log.debug("Selected protocol: %s", proto)

hyper/http20/connection.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,15 @@ def connect(self):
236236
if self._sock is None:
237237
if not self.proxy_host:
238238
host = self.host
239+
port = self.port
239240
else:
241+
host = self.proxy_host
240242
port = self.proxy_host
241243

242244
sock = socket.create_connection((host, port), 5)
243245

244246
if self.secure:
247+
assert not self.proxy_host, "Using a proxy with HTTPS not yet supported."
245248
sock, proto = wrap_socket(sock, host, self.ssl_context)
246249
else:
247250
proto = H2C_PROTOCOL

test/test_abstraction.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@ class TestHTTPConnection(object):
88
def test_h1_kwargs(self):
99
c = HTTPConnection(
1010
'test', 443, secure=False, window_manager=True, enable_push=True,
11-
ssl_context=False, proxies=False, other_kwarg=True
11+
ssl_context=False, proxy=False, other_kwarg=True
1212
)
1313

1414
assert c._h1_kwargs == {
1515
'secure': False,
1616
'ssl_context': False,
17-
'proxies': False,
17+
'proxy': False,
1818
'other_kwarg': True,
1919
}
2020

2121
def test_h2_kwargs(self):
2222
c = HTTPConnection(
2323
'test', 443, secure=False, window_manager=True, enable_push=True,
24-
ssl_context=True, proxies=False, other_kwarg=True
24+
ssl_context=True, proxy=False, other_kwarg=True
2525
)
2626

2727
assert c._h2_kwargs == {
2828
'window_manager': True,
2929
'enable_push': True,
3030
'secure': False,
3131
'ssl_context': True,
32-
'proxies': False,
32+
'proxy': False,
3333
'other_kwarg': True,
3434
}
3535

0 commit comments

Comments
 (0)