diff options
| author | Guido van Rossum <guido@python.org> | 2001-01-14 21:03:01 +0000 |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 2001-01-14 21:03:01 +0000 |
| commit | f2914de165ac180bdaadf3e3817f81eb55f9394d (patch) | |
| tree | 4f70fbd881fdb01a236a4c18cc7c8f866d657ecf /Lib | |
| parent | 8efd1f1bf698db208389b99c5481f7678f72c376 (diff) | |
| download | cpython-f2914de165ac180bdaadf3e3817f81eb55f9394d.tar.gz | |
SF Patch #103232 by dougfort: Preserve Nonstandard Port Number in Host
Header
Dougfort's comments: httplib does not include ':port ' in the HTTP 1.1
'Host:' header. This causes problems if the server is not listening
on Port 80. The test case I use is the login to /manage under Zope,
with Zope listening on port 8080. Zope returns a <frameset> with the
<frame> source URLs lacking the :8080.
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/httplib.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py index ae65a11f33..79789bbbc4 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -441,7 +441,12 @@ class HTTPConnection: # be using HTTP/1.0 and those clients may be issuing this header # themselves. we should NOT issue it twice; some web servers (such # as Apache) barf when they see two Host: headers - self.putheader('Host', self.host) + + # if we need a non-standard port,include it in the header + if self.port == HTTP_PORT: + self.putheader('Host', self.host) + else: + self.putheader('Host', "%s:%s" % (self.host, self.port)) # note: we are assuming that clients will not attempt to set these # headers since *this* library must deal with the |
