class Protocol::HTTP::Body::Rewindable

def read

@returns [String | Nil] The chunk of data, or `nil` if the stream has finished.

Read the next available chunk. This may return a buffered chunk if the stream has been rewound, or a chunk from the underlying stream, if available.
def read
	if @index < @chunks.size
		chunk = @chunks[@index]
		@index += 1
	else
		if chunk = super
			@chunks << -chunk
			@index += 1
		end
	end
	
	# We dup them on the way out, so that if someone modifies the string, it won't modify the rewindability.
	return chunk
end