From d9c0501a75e6473127b7886a42eb4a94d22aa632 Mon Sep 17 00:00:00 2001 From: ianb Date: Tue, 17 Apr 2007 17:01:06 +0000 Subject: avoid unnecessary ports in URL construction --- paste/request.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'paste/request.py') diff --git a/paste/request.py b/paste/request.py index f55ad3d..1a1d6c5 100644 --- a/paste/request.py +++ b/paste/request.py @@ -202,7 +202,19 @@ def construct_url(environ, with_query_string=True, with_path_info=True, url = environ['wsgi.url_scheme']+'://' if environ.get('HTTP_HOST'): - url += environ['HTTP_HOST'] + host = environ['HTTP_HOST'] + port = None + if ':' in host: + host, port = host.split(':', 1) + if environ['wsgi.url_scheme'] == 'https': + if port == '443': + port = None + elif environ['wsgi.url_scheme'] == 'http': + if port == '80': + port = None + url += host + if port: + url += ':%s' % port else: url += environ['SERVER_NAME'] if environ['wsgi.url_scheme'] == 'https': -- cgit v1.2.1