aboutsummaryrefslogtreecommitdiffstats
path: root/netlib
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-09-05 18:16:41 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-09-05 18:16:41 +0200
commit50bf92ccce16efc4a76640577663383323bd3b86 (patch)
tree9feb4c281e32d7b001ba8ce5fdca0cee2b266e34 /netlib
parent66ee1f465f6c492d5a4ff5659e6f0346fb243d67 (diff)
parent3ebe5a5147db20036d0762b92898f313b4d2f8d8 (diff)
downloadmitmproxy-50bf92ccce16efc4a76640577663383323bd3b86.tar.gz
mitmproxy-50bf92ccce16efc4a76640577663383323bd3b86.tar.bz2
mitmproxy-50bf92ccce16efc4a76640577663383323bd3b86.zip
Merge branch 'master' of https://github.com/mitmproxy/netlib
Diffstat (limited to 'netlib')
-rw-r--r--netlib/http/http2/protocol.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/netlib/http/http2/protocol.py b/netlib/http/http2/protocol.py
index f3254caa..b6d376d3 100644
--- a/netlib/http/http2/protocol.py
+++ b/netlib/http/http2/protocol.py
@@ -257,16 +257,21 @@ class HTTP2Protocol(semantics.ProtocolMixin):
print(frm.human_readable(">>"))
def read_frame(self, hide=False):
- frm = frame.Frame.from_file(self.tcp_handler.rfile, self)
- if not hide and self.dump_frames: # pragma no cover
- print(frm.human_readable("<<"))
- if isinstance(frm, frame.SettingsFrame) and not frm.flags & frame.Frame.FLAG_ACK:
- self._apply_settings(frm.settings, hide)
-
- if isinstance(frm, frame.DataFrame) and frm.length > 0:
- self._update_flow_control_window(frm.stream_id, frm.length)
-
- return frm
+ while True:
+ frm = frame.Frame.from_file(self.tcp_handler.rfile, self)
+ if not hide and self.dump_frames: # pragma no cover
+ print(frm.human_readable("<<"))
+
+ if isinstance(frm, frame.PingFrame):
+ raw_bytes = frame.PingFrame(flags=frame.Frame.FLAG_ACK, payload=frm.payload).to_bytes()
+ self.tcp_handler.wfile.write(raw_bytes)
+ self.tcp_handler.wfile.flush()
+ continue
+ if isinstance(frm, frame.SettingsFrame) and not frm.flags & frame.Frame.FLAG_ACK:
+ self._apply_settings(frm.settings, hide)
+ if isinstance(frm, frame.DataFrame) and frm.length > 0:
+ self._update_flow_control_window(frm.stream_id, frm.length)
+ return frm
def check_alpn(self):
alp = self.tcp_handler.get_alpn_proto_negotiated()
@@ -276,6 +281,8 @@ class HTTP2Protocol(semantics.ProtocolMixin):
return True
def _handle_unexpected_frame(self, frm):
+ if isinstance(frm, frame.SettingsFrame):
+ return
if self.unhandled_frame_cb:
self.unhandled_frame_cb(frm)