-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Conversation
urllib2 capitalize the header key and relies on this capitalization to decide whether to fill in the Content-type using the default of 'application/x-www-form-urlencoded'. If using this default, it causes tests to err with: <class 'selenium.common.exceptions.WebDriverException'>: Message: Given content type 'application/x-www-form-urlencoded' is not 'application/json;charset=UTF-8'.
@clubfest This is pretty good. Have you tested this under Python 2 and Python 3? |
It works for the webdriver tests that I have in Python 2 that were failing with the error. |
@clubfest would it be any trouble to test this change with Python 3 (3.5+)? You can create a virtual environment and just write a short script to confirm. |
Could you also provide a test in https://github.com/SeleniumHQ/selenium/blob/master/py/test/unit/selenium/webdriver/remote/test_remote_connection.py so we don't regress again? You can then run this test against Python 2/3 using Tox as detailed here: https://github.com/SeleniumHQ/selenium/wiki/Python-Bindings#tests |
It's a bit difficult to add a test for this currently, unless I create an independent function that returns the request from line 495 Or is it sufficient to add a comment to say that the request header must be modified with add_header instead of modifying the headers field? |
I am a bit confused. Many of the tests that failed are in ruby, but the change is only for python. Is there a way to re-run the continuous integration? |
@clubfest ignore the ruby test failures |
I am unable to run tests locally with tox. Am I missing some additional setup? logs: |
Yes, to get that file you need to follow the instructions here Specifically |
I ran $ ls /tmp/pip-QOi0I0-build/ |
Never mind. Just upgraded via |
For the remaining failures, I don't think they are related to my changes. Please take a look, thanks! |
Thanks! |
urllib2 capitalize the header key and relies on this capitalization to decide if the 'Content-type' field is filled in and if not, fill it in with the default of 'application/x-www-form-urlencoded'. A recent change causes the header in the request named 'Content-type' to change to 'Content-Type' and urllib2 assumes the 'Content-type' field in the request header is not filled in, so tests are using the default instead and are giving the error:
<class 'selenium.common.exceptions.WebDriverException'>: Message: Given content type 'application/x-www-form-urlencoded' is not 'application/json;charset=UTF-8'.
X
in the preceding checkbox, I verify that I have signed the Contributor License Agreement