-
Notifications
You must be signed in to change notification settings - Fork 3.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
Python 3: Add key "Content-Type" check for python 3 in webdriver test #22858
Conversation
Tracing back code in wpt/tools/webdriver/webdriver/transport.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python 2 overrides the casing in headers returned from the server? This strikes me as odd, but it does not surprise me.
In any case, the fix looks straight forward to me. Thanks!
Some of the stability tests on Chrome and Firefox are failing: Could you take a look? |
Stability checks fail because anything that touches webdriver tests takes too long for them to complete (webdriver tests are slow...). There are some diffs on Firefox and Safari results, but they look like expected flakes (the webdriver tests - or the implementations - are also flaky). Ziran; are you able to find any instances online of people reporting that headers have different cases between the two libs or between Python 2 and 3? I'd like to understand this better before making an |
Stephen, I found a similar issue reported here - |
Ok, so I spent some time digging into this, and I'm happy that this is a fundamental difference in Py2/Py3. This is repeating some of what Ziran said, but: tools/webdriver/webdriver/transport.py So we're using Python 2: Uses an HTTPMessage which is (via mimetools.Message) an rfc822.Message, which calls lower() on the header key. Python 3: Uses an email.Parser, which uses an email.FeedParser. This has horribly obtuse code (uses generators, a message passing stack, ...), but ultimately calls self.policy.header_source_parse. There are different policies but all have the same logic, and the one used is Compat32 anyway, which doesn't modify the header key. In terms of code samples, one can see this via:
Now that we have that out of the way, I'll take a look at the PR :) |
In webdriver getheaders() API of http response returns lowercase key "content-type" in python 2 and capitalized key "Content-Type" in python 3. This probably is caused by different http libraries used. Python 2 uses httplib and python 3 uses http.client for http connection.
Added comment lines as suggested. Thanks Stephen! |
This must have changed sometime between Python 3.5 (what you used) and Python 3.8 (what I just ran the test on) because the new expectation actually causes the assertion to fail, for me.
edit: pinged the wrong person |
@dralley I'm trying to reproduce the bug you mentioned above. Any particular test you ran that gave this error? |
It's possible I'm doing something wrong or there is something else "off" with my environment, but here's what I'm doing:
(this is a Servo build environment) Python details:
|
@dralley I tried this using Python 3.8.2 with Chrome browser in Ubuntu environment and didn't notice this error. |
@dralley: I can confirm that this issue exists when running firefox browser in PY3. Sorry that I wasn't able to reproduce it at the time you raised the issue! |
Further change at PR #25039 |
In webdriver getheaders() API of http response returns lowercase key
"content-type" in python 2 and capitalized key "Content-Type" in python 3.
This probably is caused by different http libraries used. Python 2 uses
httplib and python 3 uses http.client for http connection.