MCPcopy
hub / github.com/mitmproxy/mitmproxy / histogram

Method histogram

examples/addons/commands-paths.py:15–29  ·  view source on GitHub ↗
(
        self,
        flows: Sequence[flow.Flow],
        path: types.Path,
    )

Source from the content-addressed store, hash-verified

13class MyAddon:
14 @command.command("myaddon.histogram")
15 def histogram(
16 self,
17 flows: Sequence[flow.Flow],
18 path: types.Path,
19 ) -> None:
20 totals: dict[str, int] = {}
21 for f in flows:
22 if isinstance(f, http.HTTPFlow):
23 totals[f.request.host] = totals.setdefault(f.request.host, 0) + 1
24
25 with open(path, "w+") as fp:
26 for cnt, dom in sorted((v, k) for (k, v) in totals.items()):
27 fp.write(f"{cnt}: {dom}\n")
28
29 logging.log(ALERT, "done")
30
31
32addons = [MyAddon()]

Callers

nothing calls this directly

Calls 4

setdefaultMethod · 0.45
itemsMethod · 0.45
writeMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected