Skip to content

Commit

Permalink
Proper handling HTTP Host header
Browse files Browse the repository at this point in the history
Signed-off-by: Luke Inman-Semerau <[email protected]>
  • Loading branch information
grz0 authored and lukeis committed Aug 11, 2015
1 parent 7dc70b3 commit b095d43
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion py/selenium/webdriver/remote/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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', '')
Expand Down Expand Up @@ -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(),
Expand Down

1 comment on commit b095d43

@lukeis
Copy link
Member

@lukeis lukeis commented on b095d43 Sep 15, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grz0 for whatever reason this breaks the current firefox driver... had to revert it. I'm not sure why it breaks, don't have the time to investigate right now.

run ./go test_py with this change to reproduce the issue. (was using py 2.7.9 at the time)

Please sign in to comment.