Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conform to the api of urllib2 for adding header for a request #3803

Merged
merged 3 commits into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion py/selenium/webdriver/remote/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@ def _request(self, method, url, body=None):
else:
request = Request(url, data=body.encode('utf-8'), method=method)

request.headers.update(headers)
for key, val in headers.items():
request.add_header(key, val)

if password_manager:
opener = url_request.build_opener(url_request.HTTPRedirectHandler(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def getheader(self, *args, **kwargs):


def test_remote_connection_adds_connection_headers_from_get_remote_connection_headers(mocker):
test_headers = {'FOO': 'bar'}
test_headers = {'FOO': 'bar', 'Content-Type': 'json'}
expected_request_headers = {'Foo': 'bar', 'Content-type': 'json'}

# Stub out the get_remote_connection_headers method to return something testable
mocker.patch(
Expand All @@ -77,7 +78,7 @@ def test_remote_connection_adds_connection_headers_from_get_remote_connection_he
mock_open = mocker.patch('urllib2.OpenerDirector.open')

def assert_header_added(request, timeout):
assert request.headers == test_headers
assert request.headers == expected_request_headers
return MockResponse()

mock_open.side_effect = assert_header_added
Expand Down