xref: /unit/test/python/mirror/asgi.py (revision 1848:4bd548074e2c)
1async def application(scope, receive, send):
2    assert scope['type'] == 'http'
3
4    body = b''
5    while True:
6        m = await receive()
7        body += m.get('body', b'')
8        if not m.get('more_body', False):
9            break
10
11    await send(
12        {
13            'type': 'http.response.start',
14            'status': 200,
15            'headers': [(b'content-length', str(len(body)).encode())],
16        }
17    )
18
19    await send({'type': 'http.response.body', 'body': body})
20