找出 ASGI 回显应用里的 bug

来自 WSGI 与 ASGI
Python 3.14 进阶 4分钟 找出 2处问题

这个原始 ASGI 应用应回显完整请求体。找出两个协议错误。

Python
async def application(scope, receive, send):
    message = await receive()
    body = message.get("body", b"")

    await send({
        "type": "http.response.start",
        "status": 200,
        "headers": {"content-type": "text/plain"},
    })
    await send({
        "type": "http.response.body",
        "body": body,
    })
在试验场中打开
报告错误