aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/utils.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2015-08-01 11:38:02 +1200
committerAldo Cortesi <aldo@corte.si>2015-08-01 11:38:02 +1200
commit199f2a44fed6b5f1c6fada6c96b981dfab5fded2 (patch)
treecec2f094e20b2bf204f0420b67ba5774a47c9f50 /netlib/utils.py
parentfb482172241b6235da083f6dbf154b641772a4fc (diff)
parent7b10817670b30550dd45af48491ed8cf3cacd5e6 (diff)
downloadmitmproxy-199f2a44fed6b5f1c6fada6c96b981dfab5fded2.tar.gz
mitmproxy-199f2a44fed6b5f1c6fada6c96b981dfab5fded2.tar.bz2
mitmproxy-199f2a44fed6b5f1c6fada6c96b981dfab5fded2.zip
Merge pull request #84 from Kriechi/http2-wip
[WIP] Protocol Refactoring for HTTP/2
Diffstat (limited to 'netlib/utils.py')
-rw-r--r--netlib/utils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/netlib/utils.py b/netlib/utils.py
index bee412f9..86e33f33 100644
--- a/netlib/utils.py
+++ b/netlib/utils.py
@@ -129,3 +129,13 @@ class Data(object):
if not os.path.exists(fullpath):
raise ValueError("dataPath: %s does not exist." % fullpath)
return fullpath
+
+
+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)