With the ASGI framework Starlette, it has a streaming response that makes use of some more_body
parameter in the HTTP response to denote if chunks have finished streaming (source code). There is an article from Starlette talking about this: Working with ASGI and HTTP.
Is this more_body
technique a standard design pattern using HTTP, like Server Sent Events (SSE), or is it something specific to Starlette?
The
more_body
parameter used in Starlette's streaming response is not a standard HTTP feature, but a part of ASGI (Asynchronous Server Gateway Interface) specifications. It is specific to asynchronous Python web frameworks like Starlette that use ASGI.In the context of ASGI and Starlette,
more_body
is used to indicate whether the response is complete or if more data is expected. When a response is being streamed, settingmore_body
toTrue
tells the ASGI server that more data chunks are forthcoming. Once the entire response has been sent,more_body
should be set toFalse
, signaling the end of the response.That mechanism is different from standard HTTP features like Server-Sent Events (SSE). SSE is a standard that allows servers to push updates to clients over a single, long-lived HTTP connection. In contrast, the
more_body
approach is an ASGI-specific way to manage streaming responses within the framework's asynchronous processing model.