Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f6922aa

Browse files
committed
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.
1 parent 470ea5a commit f6922aa

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Lib/httplib.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,12 @@ def putrequest(self, method, url):
441441
# be using HTTP/1.0 and those clients may be issuing this header
442442
# themselves. we should NOT issue it twice; some web servers (such
443443
# as Apache) barf when they see two Host: headers
444-
self.putheader('Host', self.host)
444+
445+
# if we need a non-standard port,include it in the header
446+
if self.port == HTTP_PORT:
447+
self.putheader('Host', self.host)
448+
else:
449+
self.putheader('Host', "%s:%s" % (self.host, self.port))
445450

446451
# note: we are assuming that clients will not attempt to set these
447452
# headers since *this* library must deal with the

0 commit comments

Comments
 (0)