MCPcopy
hub / github.com/mitmproxy/mitmproxy / _unpack_params

Function _unpack_params

mitmproxy/net/dns/https_records.py:76–91  ·  view source on GitHub ↗

Unpacks the service parameters from the given offset.

(data: bytes, offset: int)

Source from the content-addressed store, hash-verified

74
75
76def _unpack_params(data: bytes, offset: int) -> dict[int, bytes]:
77 """Unpacks the service parameters from the given offset."""
78 params = {}
79 while offset < len(data):
80 param_type = struct.unpack("!H", data[offset : offset + 2])[0]
81 offset += 2
82 param_length = struct.unpack("!H", data[offset : offset + 2])[0]
83 offset += 2
84 if offset + param_length > len(data):
85 raise struct.error(
86 "unpack requires a buffer of %i bytes" % (offset + param_length)
87 )
88 param_value = data[offset : offset + param_length]
89 offset += param_length
90 params[param_type] = param_value
91 return params
92
93
94def unpack(data: bytes) -> HTTPSRecord:

Callers 1

unpackFunction · 0.85

Calls 2

unpackMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…