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

Commit fb63b9b

Browse files
committed
Allow pluggable window managers.
1 parent 1512d62 commit fb63b9b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

hyper/http20/connection.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class HTTP20Connection(object):
2727
This object behaves similarly to the Python standard library's
2828
HTTPConnection object, with a few critical differences.
2929
"""
30-
def __init__(self, host, port=None, **kwargs):
30+
def __init__(self, host, port=None, *, window_manager=None, **kwargs):
3131
"""
3232
Creates an HTTP/2.0 connection to a specific server.
3333
@@ -39,6 +39,12 @@ def __init__(self, host, port=None, **kwargs):
3939
``'twitter.com'``, ``'twitter.com:443'`` or ``'127.0.0.1'``.
4040
:param port: (optional) The port to connect to. If not provided and one
4141
also isn't provided in the ``host`` parameter, defaults to 443.
42+
:param window_manager: (optional) The class to use to manage flow
43+
control windows. This needs to be a subclass of the
44+
:class:`BaseFlowControlManager <hyper.http20.window.BaseFlowControlManager>.
45+
If not provided,
46+
:class:`FlowControlManager <hyper.http20.window.FlowControlManager>`
47+
will be used.
4248
"""
4349
if port is None:
4450
try:
@@ -50,6 +56,7 @@ def __init__(self, host, port=None, **kwargs):
5056
self.host, self.port = host, port
5157

5258
# Create the mutable state.
59+
self.__wm_class = window_manager or FlowControlManager
5360
self.__init_state()
5461

5562
return
@@ -93,8 +100,8 @@ def __init_state(self):
93100
self._out_flow_control_window = 65535
94101
self._in_flow_control_window = 65535
95102

96-
# Create the window manager.
97-
self.window_manager = FlowControlManager(65535)
103+
# Instantiate a window manager.
104+
self.window_manager = self.__wm_class(65535)
98105

99106
return
100107

0 commit comments

Comments
 (0)