Toggle flow encoding on and off, using deflate for encoding.
(self, flows: Sequence[flow.Flow], part: str)
| 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")) |