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

Commit 7a564b3

Browse files
committed
Initial spike for depending on hyper-h2.
1 parent 22afa36 commit 7a564b3

File tree

20 files changed

+342
-3282
lines changed

20 files changed

+342
-3282
lines changed

hyper/http11/connection.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
from collections import Iterable, Mapping
1414

15+
from hyperframe.frame import SettingsFrame
16+
1517
from .response import HTTP11Response
1618
from ..tls import wrap_socket, H2C_PROTOCOL
1719
from ..common.bufsocket import BufferedSocket
@@ -20,8 +22,6 @@
2022
from ..common.util import to_bytestring, to_host_port_tuple
2123
from ..compat import bytes
2224

23-
from ..packages.hyperframe.frame import SettingsFrame
24-
2525
# We prefer pycohttpparser to the pure-Python interpretation
2626
try: # pragma: no cover
2727
from pycohttpparser.api import Parser
@@ -49,13 +49,13 @@ class HTTP11Connection(object):
4949
port 443.
5050
:param ssl_context: (optional) A class with custom certificate settings.
5151
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
5353
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,
5656
defaults to 8080.
5757
"""
58-
def __init__(self, host, port=None, secure=None, ssl_context=None,
58+
def __init__(self, host, port=None, secure=None, ssl_context=None,
5959
proxy_host=None, proxy_port=None, **kwargs):
6060
if port is None:
6161
self.host, self.port = to_host_port_tuple(host, default_port=80)
@@ -112,7 +112,7 @@ def connect(self):
112112
else:
113113
host = self.proxy_host
114114
port = self.proxy_port
115-
115+
116116
sock = socket.create_connection((host, port), 5)
117117
proto = None
118118

@@ -200,8 +200,8 @@ def get_response(self):
200200

201201
self._sock.advance_buffer(response.consumed)
202202

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
205205
H2C_PROTOCOL.encode('utf-8') in headers['upgrade']):
206206
raise HTTPUpgrade(H2C_PROTOCOL, self._sock)
207207

@@ -260,7 +260,7 @@ def _add_upgrade_headers(self, headers):
260260
# Add HTTP Upgrade headers.
261261
headers[b'connection'] = b'Upgrade, HTTP2-Settings'
262262
headers[b'upgrade'] = H2C_PROTOCOL
263-
263+
264264
# Encode SETTINGS frame payload in Base64 and put into the HTTP-2 Settings header.
265265
http2_settings = SettingsFrame(0)
266266
http2_settings.settings[SettingsFrame.INITIAL_WINDOW_SIZE] = 65535

0 commit comments

Comments
 (0)