diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-02-18 16:27:09 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-02-18 16:27:09 +1300 |
commit | 6ad8b1a15d725f34990cfe3ae650fa239171a044 (patch) | |
tree | 8dc1e8ea9c06d971ac2ff1b54bf766c5266176ad /libmproxy/utils.py | |
parent | a7df6e1503551bf15c35252ffe39236221bae739 (diff) | |
download | mitmproxy-6ad8b1a15d725f34990cfe3ae650fa239171a044.tar.gz mitmproxy-6ad8b1a15d725f34990cfe3ae650fa239171a044.tar.bz2 mitmproxy-6ad8b1a15d725f34990cfe3ae650fa239171a044.zip |
Firm up reverse proxy specification.
- Extract proxy spec parsing and unparsing functions.
- Add a status indicator in mitmproxy.
- Add the "R" keybinding for changing the reverse proxy from within mitmproxy.
Diffstat (limited to 'libmproxy/utils.py')
-rw-r--r-- | libmproxy/utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libmproxy/utils.py b/libmproxy/utils.py index f0e31145..f3c36f8f 100644 --- a/libmproxy/utils.py +++ b/libmproxy/utils.py @@ -427,6 +427,23 @@ def parse_proxy_spec(url): return p[:3] +def hostport(scheme, host, port): + """ + Returns the host component, with a port specifcation if needed. + """ + if (port, scheme) in [(80, "http"), (443, "https")]: + return host + else: + return "%s:%s"%(host, port) + + +def unparse_url(scheme, host, port, path=""): + """ + Returns a URL string, constructed from the specified compnents. + """ + return "%s://%s%s"%(scheme, hostport(scheme, host, port), path) + + def clean_hanging_newline(t): """ Many editors will silently add a newline to the final line of a |