MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / ReceiveBuffer

Class ReceiveBuffer

mitmproxy/proxy/utils.py:39–68  ·  view source on GitHub ↗

A data structure to collect stream contents efficiently in O(n).

Source from the content-addressed store, hash-verified

37
38
39class ReceiveBuffer:
40 """
41 A data structure to collect stream contents efficiently in O(n).
42 """
43
44 _chunks: list[bytes]
45 _len: int
46
47 def __init__(self):
48 self._chunks = []
49 self._len = 0
50
51 def __iadd__(self, other: bytes):
52 assert isinstance(other, bytes)
53 self._chunks.append(other)
54 self._len += len(other)
55 return self
56
57 def __len__(self):
58 return self._len
59
60 def __bytes__(self):
61 return b"".join(self._chunks)
62
63 def __bool__(self):
64 return self._len > 0
65
66 def clear(self):
67 self._chunks.clear()
68 self._len = 0

Callers 4

test_receive_bufferFunction · 0.90
__init__Method · 0.90
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by 1

test_receive_bufferFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…