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 | |
parent | 9a1dd5334fed7464bac390dc8f79aa22d52773f1 (diff) | |
download | paste-d9c0501a75e6473127b7886a42eb4a94d22aa632.tar.gz |
avoid unnecessary ports in URL construction
-rw-r--r-- | docs/news.txt | 3 | ||||
-rw-r--r-- | paste/request.py | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/docs/news.txt b/docs/news.txt index 9353fe2..347f963 100644 --- a/docs/news.txt +++ b/docs/news.txt @@ -34,6 +34,9 @@ svn trunk * Fix ``paste.wsgiwrappers.WSGIRequest.urlvars`` to use ``wsgiorg.routing_args`` +* Remove port from ``paste.request.construct_url`` if it's the default + port (e.g., port 80 for ``http``). + 1.3 --- 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': |