When introducing the concept of streaming in Chapter 4, Ingesting HTTP Data, I said that request streaming was probably the less popular of the two types. I do not have any empirical data to confirm this, but it seems readily apparent to me that when most people hear the term streaming—whether they are a developer or a layperson—the implication is that there is a consumption of some form of media from the cloud.
In this section, what we are looking to achieve is to learn how we can accomplish this. How exactly does this work? When building a streaming response, Sanic will add the same
Transfer Encoding: chunked header that we saw with streaming requests. This is the indication to the client that the server is about to send incomplete data. Therefore, it should leave the connection open.
Once this happens, it is time for the server to send data at its discretion. What is a chunk of data? It follows a protocol whereby the server sends the number of...