diff --git a/python/src/uagents/asgi.py b/python/src/uagents/asgi.py index 91c840e6..9173426a 100644 --- a/python/src/uagents/asgi.py +++ b/python/src/uagents/asgi.py @@ -135,6 +135,8 @@ async def _asgi_send( header = ( [[k.encode(), v.encode()] for k, v in headers.items()] if headers else None ) + if body is None: + body = {} await send( { @@ -143,10 +145,7 @@ async def _asgi_send( "headers": header or [[b"content-type", b"application/json"]], } ) - if body: - await send( - {"type": "http.response.body", "body": json.dumps(body).encode()} - ) + await send({"type": "http.response.body", "body": json.dumps(body).encode()}) async def handle_readiness_probe(self, headers: CaseInsensitiveDict, send): """