diff options
author | Guido van Rossum <guido@python.org> | 1997-06-03 14:34:19 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-06-03 14:34:19 (GMT) |
commit | c24751b57a4e9761efe29b4ed6594af6fa955747 (patch) | |
tree | 0f2a22d616b11f83f0762c8d9ebdda746695a4b9 | |
parent | b94cd96977ac4d3c2c335ff7d72033d818d59d84 (diff) | |
download | cpython-c24751b57a4e9761efe29b4ed6594af6fa955747.zip cpython-c24751b57a4e9761efe29b4ed6594af6fa955747.tar.gz cpython-c24751b57a4e9761efe29b4ed6594af6fa955747.tar.bz2 |
Add Host: header to URL request.
-rw-r--r-- | Lib/urllib.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py index 94ddbb5..390dd63 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -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: |