In ASGI, return headers as strings and not binary (Fixes #144)
This commit is contained in:
@@ -59,8 +59,9 @@ class Microdot(BaseMicrodot):
|
||||
headers = NoCaseDict()
|
||||
content_length = 0
|
||||
for key, value in scope.get('headers', []):
|
||||
headers[key] = value
|
||||
if key.lower() == 'content-length':
|
||||
key = key.decode().title()
|
||||
headers[key] = value.decode()
|
||||
if key == 'Content-Length':
|
||||
content_length = int(value)
|
||||
|
||||
if content_length and content_length <= Request.max_body_length:
|
||||
|
||||
@@ -53,9 +53,9 @@ class TestMicrodotASGI(unittest.TestCase):
|
||||
'type': 'http',
|
||||
'path': '/foo/bar',
|
||||
'query_string': b'baz=1',
|
||||
'headers': [('Authorization', 'Bearer 123'),
|
||||
('Cookie', 'session=xyz'),
|
||||
('Content-Length', 4)],
|
||||
'headers': [(b'Authorization', b'Bearer 123'),
|
||||
(b'Cookie', b'session=xyz'),
|
||||
(b'Content-Length', b'4')],
|
||||
'client': ['1.2.3.4', 1234],
|
||||
'method': 'POST',
|
||||
'http_version': '1.1',
|
||||
@@ -114,9 +114,9 @@ class TestMicrodotASGI(unittest.TestCase):
|
||||
scope = {
|
||||
'type': 'http',
|
||||
'path': '/foo/bar',
|
||||
'headers': [('Authorization', 'Bearer 123'),
|
||||
('Cookie', 'session=xyz'),
|
||||
('Content-Length', 4)],
|
||||
'headers': [(b'Authorization', b'Bearer 123'),
|
||||
(b'Cookie', b'session=xyz'),
|
||||
(b'Content-Length', b'4')],
|
||||
'client': ['1.2.3.4', 1234],
|
||||
'method': 'POST',
|
||||
'http_version': '1.1',
|
||||
|
||||
Reference in New Issue
Block a user