-
-
Notifications
You must be signed in to change notification settings - Fork 363
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
Dictionary entries by class HeaderReader are strange #1827
Comments
Just a small followup: @staticmethod
def transform_key(key):
return str(key).title() This will cause a bytes object like |
@jaraco this one is odd. CherryPy is py3-only and Cheroot isn't. This is probably one of the issues here. What do you think we should do? |
The dict keys should be of type str regardless wether they were bytes or str. |
Maybe the right place to put a change from bytes to str would indeed be within HeaderReader of cheroot... |
I think the best thing to do is to add some validation to |
I'm fine with making cheroot Python 3-only, now that the pending pull requests have been merged/released and there's been no major issues reported. But I still don't think that will fix this issue. Since CherryPy is already Python 3-only and the user is testing on Python 3, the issue will remain even after cheroot becomes Python 3-only. The real problem is that |
The issue can be readily replicated thus:
|
It looks like the origin of This ticket probably should be against cherrypy. |
@jaraco I think we still need to add bytes-validation to |
Yes, I think so too. Having mixed bytes/text in the HeaderMap is bad form. Would you be willing to write up a ticket about that issue? |
I guess so. |
After looking into it closer, I don't think that such validation belongs there because |
β I'm submitting a ...
π Describe the bug. What is the current behavior?
From cheroot server the class HeaderReader gives strange dict entries like
{"B'Status'": b'302 Found' }
when using a predefined dictionary like the one incherrypy.serving.response.headers
.β What is the motivation / use case for changing the behavior?
The result should not contain these strange dictionary entries.
π‘ To Reproduce
Steps to reproduce the behavior:
Consider the following code:
This will result in output like
π‘ Expected behavior
The first printed dict is not ok IMHO. The second and third printed dicts show the expected entries in dict.
A lookup like
if 'Status' in dict ...
will thus fail and a workaround ist needed.π Environment
π Additional context
The text was updated successfully, but these errors were encountered: