class Async::HTTP::Body::Chunked

def empty?

def empty?
	@finished
end

def initialize(protocol)

def initialize(protocol)
	@protocol = protocol
	@finished = false
	
	@bytesize = 0
	@count = 0
end

def inspect

def inspect
	"\#<#{self.class} #{@bytesize} bytes read in #{@count} chunks>"
end

def read

def read
	return nil if @finished
	
	size = @protocol.read_line.to_i(16)
	
	if size == 0
		@protocol.read_line
		
		@finished = true
		
		return nil
	end
	
	chunk = @protocol.stream.read(size)
	@protocol.read_line # Consume the trailing CRLF
	
	@bytesize += size
	@count += 1
	
	return chunk
end