MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / ModifySpec

Class ModifySpec

mitmproxy/addons/modifyheaders.py:16–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14
15
16class ModifySpec(NamedTuple):
17 matches: flowfilter.TFilter
18 subject: bytes
19 replacement_str: str
20
21 def read_replacement(self) -> bytes:
22 """
23 Process the replacement str. This usually just involves converting it to bytes.
24 However, if it starts with `@`, we interpret the rest as a file path to read from.
25
26 Raises:
27 - IOError if the file cannot be read.
28 """
29 if self.replacement_str.startswith("@"):
30 return Path(self.replacement_str[1:]).expanduser().read_bytes()
31 else:
32 # We could cache this at some point, but unlikely to be a problem.
33 return strutils.escaped_str_to_bytes(self.replacement_str)
34
35
36def parse_modify_spec(option: str, subject_is_regex: bool) -> ModifySpec:

Callers 1

parse_modify_specFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…