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

Commit e1fd136

Browse files
committed
Merge pull request #191 from Lukasa/issue/190
Correctly initialize stream flow control windows.
2 parents 3951307 + c94507b commit e1fd136

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

hyper/http20/connection.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828

2929
log = logging.getLogger(__name__)
3030

31+
DEFAULT_WINDOW_SIZE = 65535
32+
33+
3134
class HTTP20Connection(object):
3235
"""
3336
An object representing a single HTTP/2 connection to a server.
@@ -59,7 +62,7 @@ class HTTP20Connection(object):
5962
If not provided then hyper's default ``SSLContext`` is used instead.
6063
:param proxy_host: (optional) The proxy to connect to. This can be an IP address
6164
or a host name and may include a port.
62-
:param proxy_port: (optional) The proxy port to connect to. If not provided
65+
:param proxy_port: (optional) The proxy port to connect to. If not provided
6366
and one also isn't provided in the ``proxy`` parameter, defaults to 8080.
6467
"""
6568
def __init__(self, host, port=None, secure=None, window_manager=None, enable_push=False,
@@ -137,7 +140,7 @@ def __init_state(self):
137140

138141
# Values for the settings used on an HTTP/2 connection.
139142
self._settings = {
140-
SettingsFrame.INITIAL_WINDOW_SIZE: 65535,
143+
SettingsFrame.INITIAL_WINDOW_SIZE: DEFAULT_WINDOW_SIZE,
141144
SettingsFrame.SETTINGS_MAX_FRAME_SIZE: FRAME_MAX_LEN,
142145
}
143146

@@ -513,9 +516,9 @@ def _new_stream(self, stream_id=None, local_closed=False):
513516
s = Stream(
514517
stream_id or self.next_stream_id, self._send_cb, self._recv_cb,
515518
self._close_stream, self.encoder, self.decoder,
516-
self.__wm_class(window_size), local_closed
519+
self.__wm_class(DEFAULT_WINDOW_SIZE), local_closed
517520
)
518-
s._out_flow_control_window = self._out_flow_control_window
521+
s._out_flow_control_window = window_size
519522
self.streams[s.stream_id] = s
520523
self.next_stream_id += 2
521524

test/test_hyper.py

+16
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,22 @@ def test_connections_handle_resizing_max_frame_size_properly(self):
335335
assert f2.stream_id == 0
336336
assert f2.flags == set(['ACK'])
337337

338+
def test_connections_handle_resizing_initial_window_size(self):
339+
sock = DummySocket()
340+
f = SettingsFrame(0)
341+
f.settings[SettingsFrame.INITIAL_WINDOW_SIZE] = 256
342+
c = HTTP20Connection('www.google.com')
343+
c._sock = sock
344+
345+
# 'Receive' the SETTINGS frame.
346+
c.receive_frame(f)
347+
348+
# Open a new stream.
349+
c.request('GET', '/')
350+
351+
# Confirm that the stream has the correct window size.
352+
assert c.streams[1]._out_flow_control_window == 256
353+
338354
def test_connections_handle_too_small_max_frame_size_properly(self):
339355
sock = DummySocket()
340356
f = SettingsFrame(0)

0 commit comments

Comments
 (0)