I'm reading docs of Aqueduct HTTP web server for Dart. In the section about streaming response body I see following 2 statements which do not completely fit together for me:
A body object may also be a
Stream<T>
.Stream<T>
body objects are most often used when serving files. This allows the contents of the file to be streamed from disk to the HTTP client without having to load the whole file into memory first.
and
When a body object is a
Stream<T>
, the response will not be sent until the stream is closed. For finite streams - like those from opened filed - this happens as soon as the entire file is read.
So how does it send the response only after the entire file is read without having to load the whole file into memory first?