MCPcopy
hub / github.com/mitmproxy/mitmproxy / encode_toggle

Method encode_toggle

mitmproxy/addons/core.py:200–216  ·  view source on GitHub ↗

Toggle flow encoding on and off, using deflate for encoding.

(self, flows: Sequence[flow.Flow], part: str)

Source from the content-addressed store, hash-verified

198
199 @command.command("flow.encode.toggle")
200 def encode_toggle(self, flows: Sequence[flow.Flow], part: str) -> None:
201 """
202 Toggle flow encoding on and off, using deflate for encoding.
203 """
204 updated = []
205 for f in flows:
206 p = getattr(f, part, None)
207 if p:
208 f.backup()
209 current_enc = p.headers.get("content-encoding", "identity")
210 if current_enc == "identity":
211 p.encode("deflate")
212 else:
213 p.decode()
214 updated.append(f)
215 ctx.master.addons.trigger(hooks.UpdateHook(updated))
216 logger.log(ALERT, "Toggled encoding on %s flows." % len(updated))
217
218 @command.command("flow.encode")
219 @command.argument("encoding", type=mitmproxy.types.Choice("flow.encode.options"))

Callers 1

test_encodingFunction · 0.95

Calls 7

backupMethod · 0.80
triggerMethod · 0.80
getMethod · 0.45
encodeMethod · 0.45
decodeMethod · 0.45
appendMethod · 0.45
logMethod · 0.45

Tested by 1

test_encodingFunction · 0.76