diff --git a/py/selenium/webdriver/remote/remote_connection.py b/py/selenium/webdriver/remote/remote_connection.py index e014236904953..5f153cb3f2843 100644 --- a/py/selenium/webdriver/remote/remote_connection.py +++ b/py/selenium/webdriver/remote/remote_connection.py @@ -165,6 +165,7 @@ def __init__(self, remote_server_addr, keep_alive=False): # Attempt to resolve the hostname and get an IP address. self.keep_alive = keep_alive parsed_url = parse.urlparse(remote_server_addr) + self._hostname = parsed_url.hostname addr = "" if parsed_url.hostname: try: @@ -414,7 +415,8 @@ def _request(self, method, url, body=None): headers = {"Connection": 'keep-alive', method: parsed_url.path, "User-Agent": "Python http auth", "Content-type": "application/json;charset=\"UTF-8\"", - "Accept": "application/json"} + "Accept": "application/json", + "Host": self._hostname} if parsed_url.username: auth = base64.standard_b64encode('%s:%s' % (parsed_url.username, parsed_url.password)).replace('\n', '') @@ -452,6 +454,7 @@ def _request(self, method, url, body=None): request.add_header('Accept', 'application/json') request.add_header('Content-Type', 'application/json;charset=UTF-8') + request.add_header('Host', self._hostname) if password_manager: opener = url_request.build_opener(url_request.HTTPRedirectHandler(),