From c62be0146584cfd63105ea6e68c2de188e835cce Mon Sep 17 00:00:00 2001 From: ianb Date: Thu, 4 Jan 2007 00:37:19 +0000 Subject: Respect HTTP_HOST over SERVER_PORT in construct_url --- docs/news.txt | 10 +++++++++- paste/request.py | 15 +++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/docs/news.txt b/docs/news.txt index fe347b3..7f51ffe 100644 --- a/docs/news.txt +++ b/docs/news.txt @@ -3,6 +3,14 @@ News .. contents:: +svn trunk +--------- + +* ``paste.request.construct_url`` was adding ``SERVER_PORT`` to + ``HTTP_HOST``; but ``HTTP_HOST`` (from the Host header) generally + contains a port when necessary, and ``SERVER_PORT`` should only be + used with ``SERVER_NAME``. + 1.1.1 ----- @@ -10,7 +18,7 @@ News in Paste 1.1 where most static files would return 404 Not Found). * Fixed ``parse_dict_querystring`` returning empty dicts instead of - ``MultiDict``s. + ``MultiDict``\ s. * Added ``paste.config``, a rewrite of ``paste.deploy.config`` using ``paste.registry``. This version of ``ConfigMiddleware`` will diff --git a/paste/request.py b/paste/request.py index 24de9b8..cc9bf00 100644 --- a/paste/request.py +++ b/paste/request.py @@ -202,16 +202,15 @@ 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'].split(':')[0] + url += environ['HTTP_HOST'].split(':') else: url += environ['SERVER_NAME'] - - if environ['wsgi.url_scheme'] == 'https': - if environ['SERVER_PORT'] != '443': - url += ':' + environ['SERVER_PORT'] - else: - if environ['SERVER_PORT'] != '80': - url += ':' + environ['SERVER_PORT'] + if environ['wsgi.url_scheme'] == 'https': + if environ['SERVER_PORT'] != '443': + url += ':' + environ['SERVER_PORT'] + else: + if environ['SERVER_PORT'] != '80': + url += ':' + environ['SERVER_PORT'] if script_name is None: url += urllib.quote(environ.get('SCRIPT_NAME','')) -- cgit v1.2.1