Kaydet (Commit) c24751b5 authored tarafından Guido van Rossum's avatar Guido van Rossum

Add Host: header to URL request.

üst b94cd969
...@@ -201,11 +201,14 @@ class URLopener: ...@@ -201,11 +201,14 @@ class URLopener:
if type(url) is type(""): if type(url) is type(""):
host, selector = splithost(url) host, selector = splithost(url)
user_passwd, host = splituser(host) user_passwd, host = splituser(host)
realhost = host
else: else:
host, selector = url host, selector = url
urltype, rest = splittype(selector) urltype, rest = splittype(selector)
user_passwd = None user_passwd = None
if string.lower(urltype) == 'http': if string.lower(urltype) != 'http':
realhost = None
else:
realhost, rest = splithost(rest) realhost, rest = splithost(rest)
user_passwd, realhost = splituser(realhost) user_passwd, realhost = splituser(realhost)
if user_passwd: if user_passwd:
...@@ -227,6 +230,7 @@ class URLopener: ...@@ -227,6 +230,7 @@ class URLopener:
else: else:
h.putrequest('GET', selector) h.putrequest('GET', selector)
if auth: h.putheader('Authorization', 'Basic %s' % auth) if auth: h.putheader('Authorization', 'Basic %s' % auth)
if realhost: h.putheader('Host', realhost)
for args in self.addheaders: apply(h.putheader, args) for args in self.addheaders: apply(h.putheader, args)
h.endheaders() h.endheaders()
if data is not None: if data is not None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment