aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http2/frame.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2015-06-06 12:26:48 +1200
committerAldo Cortesi <aldo@nullcube.com>2015-06-06 12:26:48 +1200
commitf2d784896dd18ea7ded9b3a95bedcdceb3325213 (patch)
treed4859f494a5b7dbfb1a13fe67887bbb1183bf942 /netlib/http2/frame.py
parentfcaabeb4556d299e8489d26f9eedc6db8fe1b86f (diff)
downloadmitmproxy-f2d784896dd18ea7ded9b3a95bedcdceb3325213.tar.gz
mitmproxy-f2d784896dd18ea7ded9b3a95bedcdceb3325213.tar.bz2
mitmproxy-f2d784896dd18ea7ded9b3a95bedcdceb3325213.zip
http2: resolve module structure and circular dependencies
- Move implementation out of __init__.py to protocol.py (an anti-pattern because it makes the kind of structural refactoring we need hard) - protocol imports frame, frame does not import protocol. To do this, we shift the default settings to frame. If this feels wrong, we can move them to a separate module (defaults.py?.).
Diffstat (limited to 'netlib/http2/frame.py')
-rw-r--r--netlib/http2/frame.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/netlib/http2/frame.py b/netlib/http2/frame.py
index 1497380a..fc86c228 100644
--- a/netlib/http2/frame.py
+++ b/netlib/http2/frame.py
@@ -38,13 +38,11 @@ class Frame(object):
raise ValueError('invalid flags detected.')
if state is None:
- from . import HTTP2Protocol
-
class State(object):
pass
state = State()
- state.http2_settings = HTTP2Protocol.HTTP2_DEFAULT_SETTINGS.copy()
+ state.http2_settings = HTTP2_DEFAULT_SETTINGS.copy()
state.encoder = Encoder()
state.decoder = Decoder()
@@ -57,12 +55,10 @@ class Frame(object):
@classmethod
def _check_frame_size(self, length, state):
- from . import HTTP2Protocol
-
if state:
settings = state.http2_settings
else:
- settings = HTTP2Protocol.HTTP2_DEFAULT_SETTINGS
+ settings = HTTP2_DEFAULT_SETTINGS.copy()
max_frame_size = settings[
SettingsFrame.SETTINGS.SETTINGS_MAX_FRAME_SIZE]
@@ -623,3 +619,13 @@ _FRAME_CLASSES = [
ContinuationFrame
]
FRAMES = {cls.TYPE: cls for cls in _FRAME_CLASSES}
+
+
+HTTP2_DEFAULT_SETTINGS = {
+ SettingsFrame.SETTINGS.SETTINGS_HEADER_TABLE_SIZE: 4096,
+ SettingsFrame.SETTINGS.SETTINGS_ENABLE_PUSH: 1,
+ SettingsFrame.SETTINGS.SETTINGS_MAX_CONCURRENT_STREAMS: None,
+ SettingsFrame.SETTINGS.SETTINGS_INITIAL_WINDOW_SIZE: 2 ** 16 - 1,
+ SettingsFrame.SETTINGS.SETTINGS_MAX_FRAME_SIZE: 2 ** 14,
+ SettingsFrame.SETTINGS.SETTINGS_MAX_HEADER_LIST_SIZE: None,
+}