From 8948703470fdb4b46adf901b2b0918fd74c4df1f Mon Sep 17 00:00:00 2001 From: rjt-gupta Date: Wed, 30 Jan 2019 16:22:16 +0530 Subject: separate editors --- mitmproxy/tools/console/consoleaddons.py | 9 ++++++--- mitmproxy/tools/console/grideditor/editors.py | 22 +++++++++++++++------- mitmproxy/tools/console/window.py | 3 ++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/mitmproxy/tools/console/consoleaddons.py b/mitmproxy/tools/console/consoleaddons.py index a40cdeaa..58f236c0 100644 --- a/mitmproxy/tools/console/consoleaddons.py +++ b/mitmproxy/tools/console/consoleaddons.py @@ -368,7 +368,8 @@ class ConsoleAddon: """ return [ "cookies", - "form", + "urlencoded form", + "multipart form", "path", "method", "query", @@ -403,8 +404,10 @@ class ConsoleAddon: flow.response = http.HTTPResponse.make() if part == "cookies": self.master.switch_view("edit_focus_cookies") - elif part == "form": - self.master.switch_view("edit_focus_form") + elif part == "urlencoded form": + self.master.switch_view("edit_focus_urlencoded_form") + elif part == "multipart form": + self.master.switch_view("edit_focus_multipart_form") elif part == "path": self.master.switch_view("edit_focus_path") elif part == "query": diff --git a/mitmproxy/tools/console/grideditor/editors.py b/mitmproxy/tools/console/grideditor/editors.py index 21cc8159..09666d58 100644 --- a/mitmproxy/tools/console/grideditor/editors.py +++ b/mitmproxy/tools/console/grideditor/editors.py @@ -53,8 +53,8 @@ class ResponseHeaderEditor(HeaderEditor): flow.response.headers = Headers(vals) -class RequestFormEditor(base.FocusEditor): - title = "Edit Form" +class RequestMultipartEditor(base.FocusEditor): + title = "Edit Multipart Form" columns = [ col_text.Column("Key"), col_text.Column("Value") @@ -62,16 +62,24 @@ class RequestFormEditor(base.FocusEditor): def get_data(self, flow): - if "application/x-www-form-urlencoded" in flow.request.headers['Content-Type']: - return flow.request.urlencoded_form.items(multi=True) - return flow.request.multipart_form.items(multi=True) def set_data(self, vals, flow): + flow.request.multipart_form = vals + + +class RequestUrlEncodedEditor(base.FocusEditor): + title = "Edit UrlEncoded Form" + columns = [ + col_text.Column("Key"), + col_text.Column("Value") + ] - if "multipart/form-data" in flow.request.headers['Content-Type']: - flow.request.multipart_form = vals + def get_data(self, flow): + return flow.request.urlencoded_form.items(multi=True) + + def set_data(self, vals, flow): flow.request.urlencoded_form = vals diff --git a/mitmproxy/tools/console/window.py b/mitmproxy/tools/console/window.py index 7669299c..fb2e8c1e 100644 --- a/mitmproxy/tools/console/window.py +++ b/mitmproxy/tools/console/window.py @@ -64,7 +64,8 @@ class WindowStack: edit_focus_cookies = grideditor.CookieEditor(master), edit_focus_setcookies = grideditor.SetCookieEditor(master), edit_focus_setcookie_attrs = grideditor.CookieAttributeEditor(master), - edit_focus_form = grideditor.RequestFormEditor(master), + edit_focus_multipart_form=grideditor.RequestMultipartEditor(master), + edit_focus_urlencoded_form=grideditor.RequestUrlEncodedEditor(master), edit_focus_path = grideditor.PathEditor(master), edit_focus_request_headers = grideditor.RequestHeaderEditor(master), edit_focus_response_headers = grideditor.ResponseHeaderEditor(master), -- cgit v1.2.3