diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-02-10 14:35:23 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-02-10 14:35:23 +1300 |
commit | 5326b7610a365d57ff06c0e72c739d2853b695f9 (patch) | |
tree | 83a8d10a9105a640771634215e49e4cff5337b24 | |
parent | 9c985f2d20e4086881bde5ecc63c21a208393894 (diff) | |
download | mitmproxy-5326b7610a365d57ff06c0e72c739d2853b695f9.tar.gz mitmproxy-5326b7610a365d57ff06c0e72c739d2853b695f9.tar.bz2 mitmproxy-5326b7610a365d57ff06c0e72c739d2853b695f9.zip |
Enable editing of urlencoded form data with KVEditor.
-rw-r--r-- | libmproxy/console/connview.py | 6 | ||||
-rw-r--r-- | libmproxy/flow.py | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/libmproxy/console/connview.py b/libmproxy/console/connview.py index 38fecfa0..1a5495db 100644 --- a/libmproxy/console/connview.py +++ b/libmproxy/console/connview.py @@ -369,6 +369,9 @@ class ConnectionView(common.WWrap): def set_query(self, lst, conn): conn.set_query(lst) + def set_form(self, lst, conn): + conn.set_form_urlencoded(lst) + def edit(self, part): if self.state.view_flow_mode == common.VIEW_FLOW_REQUEST: conn = self.flow.request @@ -381,6 +384,8 @@ class ConnectionView(common.WWrap): if part == "r": c = self.master.spawn_editor(conn.content or "") conn.content = c.rstrip("\n") + elif part == "f": + self.master.view_kveditor("Editing form", conn.get_form_urlencoded(), self.set_form, conn) elif part == "h": self.master.view_kveditor("Editing headers", conn.headers.lst, self.set_headers, conn) elif part == "q": @@ -458,6 +463,7 @@ class ConnectionView(common.WWrap): "Edit request", ( ("query", "q"), + ("form", "f"), ("url", "u"), ("header", "h"), ("raw body", "r"), diff --git a/libmproxy/flow.py b/libmproxy/flow.py index 85c48ce1..beaa85ef 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -8,7 +8,7 @@ import tnetstring, filt, script, utils, encoding, proxy from email.utils import parsedate_tz, formatdate, mktime_tz import controller, version -HDR_FORM_URLENCODED = "x-www-form-urlencoded" +HDR_FORM_URLENCODED = "application/x-www-form-urlencoded" class RunException(Exception): def __init__(self, msg, returncode, errout): @@ -332,7 +332,7 @@ class Request(HTTPMsg): Sets the body to the URL-encoded form data, and adds the appropriate content-type header. """ - self.headers["content-type"] = [HDR_FORM_URLENCODED] + self.headers["Content-Type"] = [HDR_FORM_URLENCODED] self.content = utils.urlencode(data) def get_query(self): |