aboutsummaryrefslogtreecommitdiffstats
path: root/netlib
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2015-09-03 21:22:40 +0200
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2015-09-03 21:24:07 +0200
commit53abf5f4d7c1e6f0712c6473904e5c1a58db0bb9 (patch)
tree83085eb8b77ab969379b807fc8ce22bcf5ad47f2 /netlib
parent97d224752473911f3efdba01b173dc9481e40b50 (diff)
downloadmitmproxy-53abf5f4d7c1e6f0712c6473904e5c1a58db0bb9.tar.gz
mitmproxy-53abf5f4d7c1e6f0712c6473904e5c1a58db0bb9.tar.bz2
mitmproxy-53abf5f4d7c1e6f0712c6473904e5c1a58db0bb9.zip
http2: handle Ping in protocol
Diffstat (limited to 'netlib')
-rw-r--r--netlib/http/http2/protocol.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/netlib/http/http2/protocol.py b/netlib/http/http2/protocol.py
index b297e0b8..2fbe7705 100644
--- a/netlib/http/http2/protocol.py
+++ b/netlib/http/http2/protocol.py
@@ -261,16 +261,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()