Encode flows with a specified encoding.
(
self,
flows: Sequence[flow.Flow],
part: str,
encoding: str,
)
| 218 | @command.command("flow.encode") |
| 219 | @command.argument("encoding", type=mitmproxy.types.Choice("flow.encode.options")) |
| 220 | def encode( |
| 221 | self, |
| 222 | flows: Sequence[flow.Flow], |
| 223 | part: str, |
| 224 | encoding: str, |
| 225 | ) -> None: |
| 226 | """ |
| 227 | Encode flows with a specified encoding. |
| 228 | """ |
| 229 | updated = [] |
| 230 | for f in flows: |
| 231 | p = getattr(f, part, None) |
| 232 | if p: |
| 233 | current_enc = p.headers.get("content-encoding", "identity") |
| 234 | if current_enc == "identity": |
| 235 | f.backup() |
| 236 | p.encode(encoding) |
| 237 | updated.append(f) |
| 238 | ctx.master.addons.trigger(hooks.UpdateHook(updated)) |
| 239 | logger.log(ALERT, "Encoded %s flows." % len(updated)) |
| 240 | |
| 241 | @command.command("flow.encode.options") |
| 242 | def encode_options(self) -> Sequence[str]: |