β 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 in cherrypy.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:
import tempfile
import cherrypy
from cheroot import server
response = tempfile.SpooledTemporaryFile(max_size = 1000, mode = "w+b")
response.write(b'Status: 302 Found\r\nLocation: index.php?\r\nContent-type: text/html; charset=UTF-8\r\n\r\n')
emptydict ={}
response.seek(0)
hr = server.HeaderReader()
headers = hr(response,cherrypy.serving.response.headers)
print(headers)
print(80*'-')
response.seek(0)
headers = hr(response,emptydict)
print(headers)
print(80*'-')
otherdict ={ 'Content-Type':'text/html'}
response.seek(0)
headers = hr(response,otherdict)
print(headers)
This will result in output like
{'Content-Type': 'text/html', 'Server': 'CherryPy/18.4.0', 'Date': 'Sat, 23 Nov 2019 20:10:51 GMT', "B'Status'": b'302 Found', "B'Location'": b'index.php?', "B'Content-Type'": b'text/html; charset=UTF-8'}
--------------------------------------------------------------------------------
{b'Status': b'302 Found', b'Location': b'index.php?', b'Content-Type': b'text/html; charset=UTF-8'}
--------------------------------------------------------------------------------
{'Content-Type': 'text/html', b'Status': b'302 Found', b'Location': b'index.php?', b'Content-Type': b'text/html; charset=UTF-8'}
π‘ 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
- Cheroot version: 8.2.1
- CherryPy version: 18.4.0
- Python version: 3.7.3
- OS: Debian 10 (buster)
- Browser: not relevant
π Additional context
β 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