diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-03-20 10:58:43 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-03-20 10:58:43 +1300 |
commit | 215383554525535816accdd8580d06b9e4cf7565 (patch) | |
tree | 157a8938141001336d259cdd1a778e46bec4c743 /libmproxy/console/common.py | |
parent | 2739cb4861b5d8b35ab9db0d20128b1bdc5808cb (diff) | |
download | mitmproxy-215383554525535816accdd8580d06b9e4cf7565.tar.gz mitmproxy-215383554525535816accdd8580d06b9e4cf7565.tar.bz2 mitmproxy-215383554525535816accdd8580d06b9e4cf7565.zip |
Refactor pretty view forcing somewhat.
- Use a lookup table of content types -> view modes.
- Add a urlencoded forcing. Remove "html" - at the moment it's the same as
"xmlish".
- Display type when forced.
Diffstat (limited to 'libmproxy/console/common.py')
-rw-r--r-- | libmproxy/console/common.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/libmproxy/console/common.py b/libmproxy/console/common.py index 8dbd6a98..9e8c3076 100644 --- a/libmproxy/console/common.py +++ b/libmproxy/console/common.py @@ -17,27 +17,34 @@ import urwid import urwid.util from .. import utils - VIEW_BODY_RAW = 0 VIEW_BODY_HEX = 1 VIEW_BODY_PRETTY = 2 + BODY_VIEWS = { VIEW_BODY_RAW: "raw", VIEW_BODY_HEX: "hex", VIEW_BODY_PRETTY: "pretty" } + VIEW_BODY_PRETTY_TYPE_AUTO = 0 -VIEW_BODY_PRETTY_TYPE_HTML = 1 -VIEW_BODY_PRETTY_TYPE_JSON = 2 -VIEW_BODY_PRETTY_TYPE_XML = 3 +VIEW_BODY_PRETTY_TYPE_JSON = 1 +VIEW_BODY_PRETTY_TYPE_XML = 2 +VIEW_BODY_PRETTY_TYPE_URLENCODED = 3 + +BODY_PRETTY_NAMES = { + VIEW_BODY_PRETTY_TYPE_JSON: "json", + VIEW_BODY_PRETTY_TYPE_XML: "xmlish", + VIEW_BODY_PRETTY_TYPE_URLENCODED: "urlencoded" +} BODY_PRETTY_TYPES = { - VIEW_BODY_PRETTY_TYPE_AUTO: None, - VIEW_BODY_PRETTY_TYPE_HTML: "text/html", - VIEW_BODY_PRETTY_TYPE_JSON: "application/json", - VIEW_BODY_PRETTY_TYPE_XML: "text/xml", + "text/html": VIEW_BODY_PRETTY_TYPE_XML, + "application/json": VIEW_BODY_PRETTY_TYPE_JSON, + "text/xml": VIEW_BODY_PRETTY_TYPE_XML, + "multipart/form-data": VIEW_BODY_PRETTY_TYPE_URLENCODED } |