diff options
author | pje <pje@571e12c6-e1fa-0310-aee7-ff1267fa46bd> | 2004-10-17 13:36:37 +0000 |
---|---|---|
committer | pje <pje@571e12c6-e1fa-0310-aee7-ff1267fa46bd> | 2004-10-17 13:36:37 +0000 |
commit | bc2a0536caecc2ce1d0add632ddef2d8963f106e (patch) | |
tree | 3dfc265cd0bcf0deec7392bd636788188923d38f | |
parent | 76cc7219a4e02a1031eb8a8935caf760e2a9d25e (diff) | |
download | wsgiref-bc2a0536caecc2ce1d0add632ddef2d8963f106e.tar.gz |
Fix a problem with 'application_uri()' calculation: HTTP_HOST can include
the port, so don't append SERVER_PORT unless there's no HTTP_HOST.
git-svn-id: svn://svn.eby-sarna.com/svnroot/wsgiref@258 571e12c6-e1fa-0310-aee7-ff1267fa46bd
-rw-r--r-- | src/wsgiref/tests/test_util.py | 8 | ||||
-rw-r--r-- | src/wsgiref/util.py | 12 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/wsgiref/tests/test_util.py b/src/wsgiref/tests/test_util.py index 2b82db6..b0d121f 100644 --- a/src/wsgiref/tests/test_util.py +++ b/src/wsgiref/tests/test_util.py @@ -124,14 +124,15 @@ class UtilityTests(TestCase): def testAppURIs(self): self.checkAppURI("http://127.0.0.1/") self.checkAppURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam") - self.checkAppURI("http://spam.example.com/", - HTTP_HOST="spam.example.com") + self.checkAppURI("http://spam.example.com:2071/", + HTTP_HOST="spam.example.com:2071", SERVER_PORT="2071") self.checkAppURI("http://spam.example.com/", SERVER_NAME="spam.example.com") self.checkAppURI("http://127.0.0.1/", HTTP_HOST="127.0.0.1", SERVER_NAME="spam.example.com") self.checkAppURI("https://127.0.0.1/", HTTPS="on") - self.checkAppURI("http://127.0.0.1:8000/", SERVER_PORT="8000") + self.checkAppURI("http://127.0.0.1:8000/", SERVER_PORT="8000", + HTTP_HOST=None) def testReqURIs(self): self.checkReqURI("http://127.0.0.1/") @@ -161,7 +162,6 @@ class UtilityTests(TestCase): for alt in hop, hop.title(), hop.upper(), hop.lower(): self.failIf(util.is_hop_by_hop(alt)) - TestClasses = ( UtilityTests, ) diff --git a/src/wsgiref/util.py b/src/wsgiref/util.py index dac492d..0f805ec 100644 --- a/src/wsgiref/util.py +++ b/src/wsgiref/util.py @@ -57,12 +57,12 @@ def application_uri(environ): 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'] url += quote(environ.get('SCRIPT_NAME') or '/') return url |