From a99ef584ad184658199d6ba83c73ed173f8ac0d0 Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Sun, 24 Jan 2016 23:16:50 +0100 Subject: reuse frame reading snippet --- libmproxy/utils.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libmproxy/utils.py') diff --git a/libmproxy/utils.py b/libmproxy/utils.py index a697a637..94dbbca8 100644 --- a/libmproxy/utils.py +++ b/libmproxy/utils.py @@ -173,3 +173,9 @@ def safe_subn(pattern, repl, target, *args, **kwargs): need a better solution that is aware of the actual content ecoding. """ return re.subn(str(pattern), str(repl), target, *args, **kwargs) + +def http2_read_frame(rfile): + field = rfile.peek(3) + length = int(field.encode('hex'), 16) + raw_frame = rfile.safe_read(9 + length) + return raw_frame -- cgit v1.2.3