-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
py34 test failure: KeyError: 'Authorization' error in TestSession.test_session_unicode #282
Comments
Here is what gets received, just before parsing:
From a glance it doesn't look like it's RFC 2047. It looks like it's straight UTF-8:
That seems incorrect. |
Reproducing the core problem very simply in an IPython session:
Perhaps most interesting is that midway through the value of
|
Strangely, if I manually construct the header, things seem to work better:
Note how in this case, It is curious that I was able to call |
The See: #281 -- tests are failing though. I cc'd flufl @warsaw, because he has his name on a lot of the stdlib code for email and HTTP header parsing. |
I think I'm going to take a break from this issue for a while, so anyone else who wants to dive in, feel free. |
Anyone have any ideas on how to tackle this? |
There are known problems with unicode in headers. See httpie#282
There are known problems with unicode in headers. See httpie#282
There are known problems with unicode in headers. See httpie#282
There are known problems with unicode in headers. See httpie#282
py34 test failure:
KeyError: 'Authorization'
error inTestSession.test_session_unicode
I can reproduce the
test_session_unicode
failure consistently by explicitly passing a--hashseed
to tox:From investigation in #278, I've determined that this happens because Python 3.4's HTTP header parsing chokes on the
Test
header. I think that this is because theTest
header contains UTF-8 data, which is not properly encoded.Note that you can see the
Authorization
header in the output ofstr(self.headers)
, but it's not showing up inself.headers.items()
. And theTest
header is severely truncated.I am suspicious of the
Test
header:That
Test
header is the last one that shows up inself.headers.items()
; no header that occurs after it appears -- e.g.:Accept-Encoding
,Connection
,Authorization
Also the the value is very short so I suspect that parsing is failing midway through and messing up the processing of all subsequent headers.
There's even a "defect" recorded. The email parser mentions in its comments that it doesn't throw exceptions, it records defects instead.
The root cause seems to be that the code in
email/feedparser.py
chokes on the unicode headers. And the reason why it happens only sometimes is because Pythondict
, where the request headers are stored, is unordered. So, if theAuthorization
header comes afterTest
when it's being serialized (such as when you pass--hashseed=1811760512
), it doesn't get parsed correctly at the server side and is therefore missing from httpbin's response.The text was updated successfully, but these errors were encountered: