aboutsummaryrefslogtreecommitdiffstats
path: root/netlib
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2015-08-17 22:55:33 +0200
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2015-08-18 21:22:42 +0200
commit0d384ac2a91898d4c8623290ae0fb3a60a35e514 (patch)
tree8396169d0ebd6495f30c70fb060c8825320bbd12 /netlib
parent12efa61e3af1b0ede4a803320b6f2a14b034aa5d (diff)
downloadmitmproxy-0d384ac2a91898d4c8623290ae0fb3a60a35e514.tar.gz
mitmproxy-0d384ac2a91898d4c8623290ae0fb3a60a35e514.tar.bz2
mitmproxy-0d384ac2a91898d4c8623290ae0fb3a60a35e514.zip
http2: add support for too large data frames
Diffstat (limited to 'netlib')
-rw-r--r--netlib/http/http2/protocol.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/netlib/http/http2/protocol.py b/netlib/http/http2/protocol.py
index c2ad5edd..cc8daba8 100644
--- a/netlib/http/http2/protocol.py
+++ b/netlib/http/http2/protocol.py
@@ -297,19 +297,22 @@ class HTTP2Protocol(semantics.ProtocolMixin):
if body is None or len(body) == 0:
return b''
- # TODO: implement max frame size checks and sending in chunks
- # TODO: implement flow-control window
-
- frm = frame.DataFrame(
+ chunk_size = self.http2_settings[frame.SettingsFrame.SETTINGS.SETTINGS_MAX_FRAME_SIZE]
+ chunks = range(0, len(body), chunk_size)
+ frms = [frame.DataFrame(
state=self,
- flags=frame.Frame.FLAG_END_STREAM,
+ flags=frame.Frame.FLAG_NO_FLAGS,
stream_id=stream_id,
- payload=body)
+ payload=body[i:i+chunk_size]) for i in chunks]
+ frms[-1].flags = frame.Frame.FLAG_END_STREAM
+
+ # TODO: implement flow-control window
if self.dump_frames: # pragma no cover
- print(frm.human_readable(">>"))
+ for frm in frms:
+ print(frm.human_readable(">>"))
- return [frm.to_bytes()]
+ return [frm.to_bytes() for frm in frms]
def _receive_transmission(self, include_body=True):
body_expected = True