Skip to content

Commit b095d43

Browse files
grz0lukeis
authored andcommitted
Proper handling HTTP Host header
Signed-off-by: Luke Inman-Semerau <[email protected]>
1 parent 7dc70b3 commit b095d43

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

py/selenium/webdriver/remote/remote_connection.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def __init__(self, remote_server_addr, keep_alive=False):
165165
# Attempt to resolve the hostname and get an IP address.
166166
self.keep_alive = keep_alive
167167
parsed_url = parse.urlparse(remote_server_addr)
168+
self._hostname = parsed_url.hostname
168169
addr = ""
169170
if parsed_url.hostname:
170171
try:
@@ -414,7 +415,8 @@ def _request(self, method, url, body=None):
414415
headers = {"Connection": 'keep-alive', method: parsed_url.path,
415416
"User-Agent": "Python http auth",
416417
"Content-type": "application/json;charset=\"UTF-8\"",
417-
"Accept": "application/json"}
418+
"Accept": "application/json",
419+
"Host": self._hostname}
418420
if parsed_url.username:
419421
auth = base64.standard_b64encode('%s:%s' %
420422
(parsed_url.username, parsed_url.password)).replace('\n', '')
@@ -452,6 +454,7 @@ def _request(self, method, url, body=None):
452454

453455
request.add_header('Accept', 'application/json')
454456
request.add_header('Content-Type', 'application/json;charset=UTF-8')
457+
request.add_header('Host', self._hostname)
455458

456459
if password_manager:
457460
opener = url_request.build_opener(url_request.HTTPRedirectHandler(),

0 commit comments

Comments
 (0)