class Async::HTTP::Body::Readable

A generic base class for wrapping body instances. Typically you’d override ‘#read`.

def close

Buffer any remaining body.
def close
	Buffered.for(self)
end

def each

Enumerate all chunks until finished. If an error is thrown, #stop will be invoked.
def each
	return to_enum unless block_given?
	
	while chunk = self.read
		yield chunk
	end
rescue
	stop($!)
	
	raise
end

def empty?

Will read return any data?
def empty?
	false
end

def join

Read all remaining chunks into a single binary string.
def join
	buffer = IO::BinaryString.new
	
	self.each do |chunk|
		buffer << chunk
	end
	
	return buffer
end

def read

Read the next available chunk.
def read
	nil
end

def stop(error)

The consumer can call stop to signal that the stream output has terminated.
def stop(error)
end