diff options
author | Matthew Shao <me@matshao.com> | 2017-07-26 15:06:42 +0800 |
---|---|---|
committer | Matthew Shao <me@matshao.com> | 2017-07-26 15:06:42 +0800 |
commit | 9d16cc7079984661c9268a36c4e45bdcb5c7ea19 (patch) | |
tree | 64c9bed3a08bed8c3387b865afba18fe24f3db2b | |
parent | 5c45a90ce961d740e59644f4de0f8ffe97a5706c (diff) | |
download | mitmproxy-9d16cc7079984661c9268a36c4e45bdcb5c7ea19.tar.gz mitmproxy-9d16cc7079984661c9268a36c4e45bdcb5c7ea19.tar.bz2 mitmproxy-9d16cc7079984661c9268a36c4e45bdcb5c7ea19.zip |
[web] Update POST /options/dump API in backend.
-rw-r--r-- | mitmproxy/tools/web/app.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/mitmproxy/tools/web/app.py b/mitmproxy/tools/web/app.py index 36cb1ca1..f9f44162 100644 --- a/mitmproxy/tools/web/app.py +++ b/mitmproxy/tools/web/app.py @@ -18,8 +18,10 @@ from mitmproxy import io from mitmproxy import log from mitmproxy import version from mitmproxy import optmanager +from mitmproxy import options import mitmproxy.tools.web.master # noqa +CONFIG_PATH = os.path.expanduser(os.path.join(options.CA_DIR, 'config.yaml')) def flow_to_json(flow: mitmproxy.flow.Flow) -> dict: """ @@ -452,17 +454,9 @@ class Options(RequestHandler): 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) + optmanager.save(self.master.options, CONFIG_PATH) except Exception as err: raise APIError(400, "{}".format(err)) |