class Async::HTTP::FixedBody

def each

def each
	while chunk = self.read
		yield chunk
	end
end

def finish

def finish
	read
end

def finished?

def finished?
	@remaining == 0
end

def initialize(length, stream)

def initialize(length, stream)
	@length = length
	@remaining = length
	@stream = stream
end

def join

def join
	buffer = @stream.read(@remaining)
	
	@remaining = 0
	
	return buffer
end

def read

def read
	if @remaining > 0
		if chunk = @stream.read(@remaining)
			@remaining -= chunk.bytesize
			
			return chunk
		end
	end
end