]> granicus.if.org Git - python/commitdiff
Add Host: header to URL request.
authorGuido van Rossum <guido@python.org>
Tue, 3 Jun 1997 14:34:19 +0000 (14:34 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 3 Jun 1997 14:34:19 +0000 (14:34 +0000)
Lib/urllib.py

index 94ddbb5343efe54934cb67395332a47f070c3cc6..390dd636340eb8f8f142b930055792dc7e8c2a74 100644 (file)
@@ -201,11 +201,14 @@ class URLopener:
                if type(url) is type(""):
                        host, selector = splithost(url)
                        user_passwd, host = splituser(host)
+                       realhost = host
                else:
                        host, selector = url
                        urltype, rest = splittype(selector)
                        user_passwd = None
-                       if string.lower(urltype) == 'http':
+                       if string.lower(urltype) != 'http':
+                           realhost = None
+                       else:
                            realhost, rest = splithost(rest)
                            user_passwd, realhost = splituser(realhost)
                            if user_passwd:
@@ -227,6 +230,7 @@ class URLopener:
                else:
                        h.putrequest('GET', selector)
                if auth: h.putheader('Authorization', 'Basic %s' % auth)
+               if realhost: h.putheader('Host', realhost)
                for args in self.addheaders: apply(h.putheader, args)
                h.endheaders()
                if data is not None: