class Protocol::HTTP::Body::Readable
def call(stream)
@parameter stream [IO | Object] An `IO`-like object that responds to `#read`, `#write` and `#flush`.
Write the body to the given stream.
The default implementation simply writes each chunk to the stream. If the body is not ready, it will be flushed after each chunk. Closes the stream when finished or if an error occurs.
Invoke the body with the given stream.
def call(stream) self.each do |chunk| stream.write(chunk) # Flush the stream unless we are immediately expecting more data: unless self.ready? stream.flush end end ensure stream.close end