diff options
| author | Aldo Cortesi <aldo@nullcube.com> | 2016-11-02 11:58:27 +1300 |
|---|---|---|
| committer | Aldo Cortesi <aldo@nullcube.com> | 2016-11-02 22:47:49 +1300 |
| commit | b867fb35a3066138d5e1b835930f42153ab24657 (patch) | |
| tree | b319d9754cc263eb14e5a99eed23c48d461d30b7 /test/mitmproxy/addons/dumperview.py | |
| parent | a75b3474a4520b15134f025a1cb58ebce84879c7 (diff) | |
| download | mitmproxy-b867fb35a3066138d5e1b835930f42153ab24657.tar.gz mitmproxy-b867fb35a3066138d5e1b835930f42153ab24657.tar.bz2 mitmproxy-b867fb35a3066138d5e1b835930f42153ab24657.zip | |
addons: dumper spit and polish
- 100% test coverage
- Cleanups
- Add test/mitmproxy/addons/dumperview.py, a small utility for viewing dumper
output variations
Diffstat (limited to 'test/mitmproxy/addons/dumperview.py')
| -rwxr-xr-x | test/mitmproxy/addons/dumperview.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/mitmproxy/addons/dumperview.py b/test/mitmproxy/addons/dumperview.py new file mode 100755 index 00000000..be56fe14 --- /dev/null +++ b/test/mitmproxy/addons/dumperview.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +import click + +from mitmproxy.addons import dumper +from mitmproxy.test import tflow +from mitmproxy.test import taddons +from mitmproxy.tools import dump + + +def show(flow_detail, flows): + d = dumper.Dumper() + with taddons.context(options=dump.Options()) as ctx: + ctx.configure(d, flow_detail=flow_detail) + for f in flows: + ctx.cycle(d, f) + + +@click.group() +def cli(): + pass + + +@cli.command() +@click.option('--level', default=1, help='Detail level') +def tcp(level): + f1 = tflow.ttcpflow(client_conn=True, server_conn=True) + show(level, [f1]) + + +@cli.command() +@click.option('--level', default=1, help='Detail level') +def large(level): + f1 = tflow.tflow(client_conn=True, server_conn=True, resp=True) + f1.response.headers["content-type"] = "text/html" + f1.response.content = b"foo bar voing\n" * 100 + show(level, [f1]) + + +@cli.command() +@click.option('--level', default=1, help='Detail level') +def small(level): + f1 = tflow.tflow(client_conn=True, server_conn=True, resp=True) + f1.response.headers["content-type"] = "text/html" + f1.response.content = b"<html><body>Hello!</body></html>" + + f2 = tflow.tflow(client_conn=True, server_conn=True, err=True) + + show( + level, + [ + f1, f2, + ] + ) + + +if __name__ == "__main__": + cli() |
