@@ -165,6 +165,7 @@ def __init__(self, remote_server_addr, keep_alive=False):
165
165
# Attempt to resolve the hostname and get an IP address.
166
166
self .keep_alive = keep_alive
167
167
parsed_url = parse .urlparse (remote_server_addr )
168
+ self ._hostname = parsed_url .hostname
168
169
addr = ""
169
170
if parsed_url .hostname :
170
171
try :
@@ -414,7 +415,8 @@ def _request(self, method, url, body=None):
414
415
headers = {"Connection" : 'keep-alive' , method : parsed_url .path ,
415
416
"User-Agent" : "Python http auth" ,
416
417
"Content-type" : "application/json;charset=\" UTF-8\" " ,
417
- "Accept" : "application/json" }
418
+ "Accept" : "application/json" ,
419
+ "Host" : self ._hostname }
418
420
if parsed_url .username :
419
421
auth = base64 .standard_b64encode ('%s:%s' %
420
422
(parsed_url .username , parsed_url .password )).replace ('\n ' , '' )
@@ -452,6 +454,7 @@ def _request(self, method, url, body=None):
452
454
453
455
request .add_header ('Accept' , 'application/json' )
454
456
request .add_header ('Content-Type' , 'application/json;charset=UTF-8' )
457
+ request .add_header ('Host' , self ._hostname )
455
458
456
459
if password_manager :
457
460
opener = url_request .build_opener (url_request .HTTPRedirectHandler (),
0 commit comments