diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-06-18 12:07:02 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-06-18 12:07:02 +1200 |
commit | 5bb7159edd7bf1d54b75969a2d3859e9570e8361 (patch) | |
tree | 8d0d7b909a5432fcb7317c95fc70aec1927d67b2 /netlib/http2/frame.py | |
parent | 1f0c55a942ef1e36d21e2d8006a1585ad4cf2700 (diff) | |
parent | eb823a04a19de7fd9e15d225064ae4581f0b85bf (diff) | |
download | mitmproxy-5bb7159edd7bf1d54b75969a2d3859e9570e8361.tar.gz mitmproxy-5bb7159edd7bf1d54b75969a2d3859e9570e8361.tar.bz2 mitmproxy-5bb7159edd7bf1d54b75969a2d3859e9570e8361.zip |
Merge pull request #70 from Kriechi/http2-wip
HTTP/2: yet another PR
Diffstat (limited to 'netlib/http2/frame.py')
-rw-r--r-- | netlib/http2/frame.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/netlib/http2/frame.py b/netlib/http2/frame.py index 4a305d82..98ced904 100644 --- a/netlib/http2/frame.py +++ b/netlib/http2/frame.py @@ -113,16 +113,13 @@ class Frame(object): def payload_human_readable(self): # pragma: no cover raise NotImplementedError() - def human_readable(self): + def human_readable(self, direction="-"): + self.length = len(self.payload_bytes()) + return "\n".join([ - "============================================================", - "length: %d bytes" % self.length, - "type: %s (%#x)" % (self.__class__.__name__, self.TYPE), - "flags: %#x" % self.flags, - "stream_id: %#x" % self.stream_id, - "------------------------------------------------------------", + "%s: %s | length: %d | flags: %#x | stream_id: %d" % (direction, self.__class__.__name__, self.length, self.flags, self.stream_id), self.payload_human_readable(), - "============================================================", + "===============================================================", ]) def __eq__(self, other): @@ -461,7 +458,10 @@ class PushPromiseFrame(Frame): s.append("padding: %d" % self.pad_length) s.append("promised stream: %#x" % self.promised_stream) - s.append("header_block_fragment: %s" % str(self.header_block_fragment)) + s.append( + "header_block_fragment: %s" % + self.header_block_fragment.encode('hex')) + return "\n".join(s) @@ -605,7 +605,11 @@ class ContinuationFrame(Frame): return self.header_block_fragment def payload_human_readable(self): - return "header_block_fragment: %s" % str(self.header_block_fragment) + s = [] + s.append( + "header_block_fragment: %s" % + self.header_block_fragment.encode('hex')) + return "\n".join(s) _FRAME_CLASSES = [ DataFrame, |