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

Commit dc20403

Browse files
committed
Merge pull request #212 from Lukasa/h2
Depend on hyper-h2.
2 parents 2494811 + fea1359 commit dc20403

27 files changed

+675
-3319
lines changed

.coveragerc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
[run]
2+
source = hyper
23
omit =
34
hyper/compat.py
45
hyper/httplib_compat.py
56
hyper/ssl_compat.py
67
hyper/packages/*
8+
9+
[report]
10+
fail_under = 100
11+
show_missing = True
12+
13+
[paths]
14+
source =
15+
hyper/
16+
.tox/*/lib/python*/site-packages/hyper
17+
.tox/pypy*/site-packages/hyper

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ language: python
22

33
python:
44
- "2.7"
5-
- "3.3"
65
- "3.4"
6+
- "3.5"
77
- pypy
88

99
env:
@@ -31,7 +31,8 @@ script:
3131
if [[ $TRAVIS_PYTHON_VERSION == pypy ]]; then
3232
py.test test/
3333
else
34-
py.test -n 1 --cov hyper test/
35-
coverage report -m --fail-under 100
34+
coverage run -m py.test test/
35+
coverage combine
36+
coverage report
3637
fi
3738
fi

hyper/common/bufsocket.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ def can_read(self):
6767
"""
6868
Whether or not there is more data to read from the socket.
6969
"""
70-
if self._bytes_in_buffer:
71-
return True
72-
7370
read = select.select([self._sck], [], [], 0)[0]
7471
if read:
7572
return True

hyper/common/headers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def replace(self, key, value):
187187
method work like ``__setitem__``. Replacing leads to deletion of all
188188
existing headers with the same name.
189189
"""
190-
key = to_bytestring(key)
190+
key, value = to_bytestring_tuple(key, value)
191191
indices = []
192192
for (i, (k, v)) in enumerate(self._items):
193193
if _keys_equal(k, key):

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)