From a5d9e1f44dbe0fc6fee174b1953806f9b148b5ad Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Wed, 29 Jul 2015 11:39:53 +0200 Subject: move code to netlib and implement protocols --- libmproxy/utils.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'libmproxy/utils.py') diff --git a/libmproxy/utils.py b/libmproxy/utils.py index a29a53f5..78f74767 100644 --- a/libmproxy/utils.py +++ b/libmproxy/utils.py @@ -8,6 +8,7 @@ import functools import cgi import json +import netlib.utils def timestamp(): """ @@ -195,21 +196,12 @@ def parse_content_type(c): return ts[0].lower(), ts[1].lower(), d -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) + return "%s://%s%s" % (scheme, netlib.utils.hostport(scheme, host, port), path) def clean_hanging_newline(t): -- cgit v1.2.3