diff options
author | ianb <devnull@localhost> | 2007-04-17 17:01:06 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2007-04-17 17:01:06 +0000 |
commit | d9c0501a75e6473127b7886a42eb4a94d22aa632 (patch) | |
tree | 222e63fb848f80cf00a8ab440439b08f39f9f71f /paste/request.py | |
parent | 9a1dd5334fed7464bac390dc8f79aa22d52773f1 (diff) | |
download | paste-d9c0501a75e6473127b7886a42eb4a94d22aa632.tar.gz |
avoid unnecessary ports in URL construction
Diffstat (limited to 'paste/request.py')
-rw-r--r-- | paste/request.py | 14 |
1 files changed, 13 insertions, 1 deletions
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': |