always encode ASGI response bodies to bytes
This commit is contained in:
@@ -130,6 +130,8 @@ class Microdot(BaseMicrodot):
|
||||
try:
|
||||
while not cancelled: # pragma: no branch
|
||||
res_body = await body_iter.__anext__()
|
||||
if isinstance(res_body, str):
|
||||
res_body = res_body.encode()
|
||||
await send({'type': 'http.response.body',
|
||||
'body': res_body,
|
||||
'more_body': True})
|
||||
|
||||
@@ -35,7 +35,7 @@ class TestASGI(unittest.TestCase):
|
||||
class R:
|
||||
def __init__(self):
|
||||
self.i = 0
|
||||
self.body = [b're', b'sp', b'on', b'se', b'']
|
||||
self.body = [b're', b'sp', b'on', 'se', b'']
|
||||
|
||||
async def read(self, n):
|
||||
data = self.body[self.i]
|
||||
|
||||
Reference in New Issue
Block a user