xref: /unit/test/python/targets/asgi.py (revision 1873:d0cc4fd78d43)
1async def application_201(scope, receive, send):
2    assert scope['type'] == 'http'
3
4    await send(
5        {
6            'type': 'http.response.start',
7            'status': 201,
8            'headers': [(b'content-length', b'0')],
9        }
10    )
11
12
13async def application_200(scope, receive, send):
14    assert scope['type'] == 'http'
15
16    await send(
17        {
18            'type': 'http.response.start',
19            'status': 200,
20            'headers': [(b'content-length', b'0')],
21        }
22    )
23
24
25def legacy_application_200(scope):
26    assert scope['type'] == 'http'
27
28    return legacy_app_http_200
29
30
31async def legacy_app_http_200(receive, send):
32    await send(
33        {
34            'type': 'http.response.start',
35            'status': 200,
36            'headers': [(b'content-length', b'0')],
37        }
38    )
39
40
41def legacy_application_201(scope, receive=None, send=None):
42    assert scope['type'] == 'http'
43
44    return legacy_app_http_201
45
46
47async def legacy_app_http_201(receive, send):
48    await send(
49        {
50            'type': 'http.response.start',
51            'status': 201,
52            'headers': [(b'content-length', b'0')],
53        }
54    )
55