MCPcopy
hub / github.com/mitmproxy/mitmproxy / TCPMessage

Class TCPMessage

mitmproxy/tcp.py:8–34  ·  view source on GitHub ↗

An individual TCP "message". Note that TCP is *stream-based* and not *message-based*. For practical purposes the stream is chunked into messages here, but you should not rely on message boundaries.

Source from the content-addressed store, hash-verified

6
7
8class TCPMessage(serializable.Serializable):
9 """
10 An individual TCP "message".
11 Note that TCP is *stream-based* and not *message-based*.
12 For practical purposes the stream is chunked into messages here,
13 but you should not rely on message boundaries.
14 """
15
16 def __init__(self, from_client, content, timestamp=None):
17 self.from_client = from_client
18 self.content = content
19 self.timestamp = timestamp or time.time()
20
21 @classmethod
22 def from_state(cls, state):
23 return cls(*state)
24
25 def get_state(self):
26 return self.from_client, self.content, self.timestamp
27
28 def set_state(self, state):
29 self.from_client, self.content, self.timestamp = state
30
31 def __repr__(self):
32 return "{direction} {content}".format(
33 direction="->" if self.from_client else "<-", content=repr(self.content)
34 )
35
36
37class TCPFlow(flow.Flow):

Callers 5

test_injectFunction · 0.90
test_http_proxy_tcpFunction · 0.90
test_view_http3Function · 0.90
test_tcpFunction · 0.90

Calls

no outgoing calls

Tested by 5

test_injectFunction · 0.72
test_http_proxy_tcpFunction · 0.72
test_view_http3Function · 0.72
test_tcpFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…