diff options
author | Matthew Shao <me@matshao.com> | 2017-07-24 20:32:46 +0800 |
---|---|---|
committer | Matthew Shao <me@matshao.com> | 2017-07-24 20:32:46 +0800 |
commit | 38d926d159221d7e4a4bd2c895a040f351f5264f (patch) | |
tree | 984f0e0cbae499cc2bccbf726034deeb3ee520b5 | |
parent | 6c4dbcc7a7774f7acbad0f1362a94525316d51ff (diff) | |
download | mitmproxy-38d926d159221d7e4a4bd2c895a040f351f5264f.tar.gz mitmproxy-38d926d159221d7e4a4bd2c895a040f351f5264f.tar.bz2 mitmproxy-38d926d159221d7e4a4bd2c895a040f351f5264f.zip |
[web] Add /options/dump API to backend.
-rw-r--r-- | mitmproxy/tools/web/app.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/mitmproxy/tools/web/app.py b/mitmproxy/tools/web/app.py index c6fb2ef6..36cb1ca1 100644 --- a/mitmproxy/tools/web/app.py +++ b/mitmproxy/tools/web/app.py @@ -451,6 +451,22 @@ class Options(RequestHandler): raise APIError(400, "{}".format(err)) +class DumpOptions(RequestHandler): + def get(self): + self.set_header("Content-Disposition", "attachment; filename=options") + self.set_header("Content-Type", "application/octet-stream") + + data = optmanager.save(self.master.options) + self.write(data) + + def post(self): + try: + data = optmanager.parse(self.filecontents) + self.master.options.update(**data) + except Exception as err: + raise APIError(400, "{}".format(err)) + + class Application(tornado.web.Application): def __init__(self, master, debug): self.master = master @@ -475,7 +491,8 @@ class Application(tornado.web.Application): FlowContentView), (r"/settings", Settings), (r"/clear", ClearAll), - (r"/options", Options) + (r"/options", Options), + (r"/options/dump", DumpOptions) ] settings = dict( template_path=os.path.join(os.path.dirname(__file__), "templates"), |