summaryrefslogtreecommitdiffhomepage
path: root/test/python/body_bytearray/asgi.py
diff options
context:
space:
mode:
authorDan Callahan <d.callahan@f5.com>2024-02-27 15:15:42 +0000
committerDan Callahan <d.callahan@f5.com>2024-02-27 15:15:42 +0000
commitd76761901c4084bcdbc5a449e9bbb47d56b7093c (patch)
treeb4b7b4e3d588b73a2adcc0094cab466d9194c679 /test/python/body_bytearray/asgi.py
parentc43629880472bba8d389dfb0b7ae6d883b0ba499 (diff)
parent088117008c9e8f397a58cc8d8070ce047beff12f (diff)
downloadunit-1.32.0-1.tar.gz
unit-1.32.0-1.tar.bz2
Merge tag '1.32.0' into branches/packaging1.32.0-1
Unit 1.32.0 release.
Diffstat (limited to '')
-rw-r--r--test/python/body_bytearray/asgi.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/python/body_bytearray/asgi.py b/test/python/body_bytearray/asgi.py
new file mode 100644
index 00000000..6d2f402f
--- /dev/null
+++ b/test/python/body_bytearray/asgi.py
@@ -0,0 +1,20 @@
+async def application(scope, receive, send):
+ assert scope['type'] == 'http'
+
+ body = b''
+ while True:
+ m = await receive()
+ body += m.get('body', b'')
+ if not m.get('more_body', False):
+ body = bytearray(body)
+ break
+
+ await send(
+ {
+ 'type': 'http.response.start',
+ 'status': 200,
+ 'headers': [(b'content-length', str(len(body)).encode())],
+ }
+ )
+
+ await send({'type': 'http.response.body', 'body': body})