class Async::HTTP::Body::File

def empty?

def empty?
	@remaining == 0
end

def initialize(path, range = nil, block_size: Async::IO::Stream::BLOCK_SIZE)

def initialize(path, range = nil, block_size: Async::IO::Stream::BLOCK_SIZE)
	@path = path
	@file = File.open(path)
	
	@block_size = block_size
	
	if range
		@offset = range.min
		@length = @remaining = range.size
	else
		@offset = 0
		@length = @remaining = @file.size
	end
end

def inspect

def inspect
	"\#<#{self.class} path=#{@path} offset=#{@offset} remaining=#{@remaining}>"
end

def join

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

def read

def read
	if @remaining > 0
		amount = [@remaining, @block_size].min
		
		if chunk = @file.read(amount)
			@remaining -= chunk.bytesize
			
			return chunk
		else
			@file.close
		end
	end
end