class Protocol::HTTP::Body::Streamable::Body

def call(stream)

@parameter stream [Stream] The stream to read and write to.

Invoke the block with the given stream. The block can read and write to the stream, and must close the stream when finishing.
def call(stream)
	if @block.nil?
		raise ConsumedError, "Streaming block has already been consumed!"
	end
	
	block = @block
	
	@input = @output = @block = nil
	
	# Ownership of the stream is passed into the block, in other words, the block is responsible for closing the stream.
	block.call(stream)
rescue => error
	# If, for some reason, the block raises an error, we assume it may not have closed the stream, so we close it here:
	stream.close
	raise
end