|
12 | 12 |
|
13 | 13 | from collections import Iterable, Mapping |
14 | 14 |
|
| 15 | +from hyperframe.frame import SettingsFrame |
| 16 | + |
15 | 17 | from .response import HTTP11Response |
16 | 18 | from ..tls import wrap_socket, H2C_PROTOCOL |
17 | 19 | from ..common.bufsocket import BufferedSocket |
|
20 | 22 | from ..common.util import to_bytestring, to_host_port_tuple |
21 | 23 | from ..compat import bytes |
22 | 24 |
|
23 | | -from ..packages.hyperframe.frame import SettingsFrame |
24 | | - |
25 | 25 | # We prefer pycohttpparser to the pure-Python interpretation |
26 | 26 | try: # pragma: no cover |
27 | 27 | from pycohttpparser.api import Parser |
@@ -49,13 +49,13 @@ class HTTP11Connection(object): |
49 | 49 | port 443. |
50 | 50 | :param ssl_context: (optional) A class with custom certificate settings. |
51 | 51 | If not provided then hyper's default ``SSLContext`` is used instead. |
52 | | - :param proxy_host: (optional) The proxy to connect to. This can be an IP |
| 52 | + :param proxy_host: (optional) The proxy to connect to. This can be an IP |
53 | 53 | address or a host name and may include a port. |
54 | | - :param proxy_port: (optional) The proxy port to connect to. If not provided |
55 | | - and one also isn't provided in the ``proxy`` parameter, |
| 54 | + :param proxy_port: (optional) The proxy port to connect to. If not provided |
| 55 | + and one also isn't provided in the ``proxy`` parameter, |
56 | 56 | defaults to 8080. |
57 | 57 | """ |
58 | | - def __init__(self, host, port=None, secure=None, ssl_context=None, |
| 58 | + def __init__(self, host, port=None, secure=None, ssl_context=None, |
59 | 59 | proxy_host=None, proxy_port=None, **kwargs): |
60 | 60 | if port is None: |
61 | 61 | self.host, self.port = to_host_port_tuple(host, default_port=80) |
@@ -112,7 +112,7 @@ def connect(self): |
112 | 112 | else: |
113 | 113 | host = self.proxy_host |
114 | 114 | port = self.proxy_port |
115 | | - |
| 115 | + |
116 | 116 | sock = socket.create_connection((host, port), 5) |
117 | 117 | proto = None |
118 | 118 |
|
@@ -200,8 +200,8 @@ def get_response(self): |
200 | 200 |
|
201 | 201 | self._sock.advance_buffer(response.consumed) |
202 | 202 |
|
203 | | - if (response.status == 101 and |
204 | | - b'upgrade' in headers['connection'] and |
| 203 | + if (response.status == 101 and |
| 204 | + b'upgrade' in headers['connection'] and |
205 | 205 | H2C_PROTOCOL.encode('utf-8') in headers['upgrade']): |
206 | 206 | raise HTTPUpgrade(H2C_PROTOCOL, self._sock) |
207 | 207 |
|
@@ -260,7 +260,7 @@ def _add_upgrade_headers(self, headers): |
260 | 260 | # Add HTTP Upgrade headers. |
261 | 261 | headers[b'connection'] = b'Upgrade, HTTP2-Settings' |
262 | 262 | headers[b'upgrade'] = H2C_PROTOCOL |
263 | | - |
| 263 | + |
264 | 264 | # Encode SETTINGS frame payload in Base64 and put into the HTTP-2 Settings header. |
265 | 265 | http2_settings = SettingsFrame(0) |
266 | 266 | http2_settings.settings[SettingsFrame.INITIAL_WINDOW_SIZE] = 65535 |
|
0 commit comments