class Async::HTTP::Body::Deflate

def read

def read
	return if @stream.closed?
	
	if chunk = super
		@input_length += chunk.bytesize
		
		chunk = @stream.deflate(chunk, Zlib::SYNC_FLUSH)
		
		@output_length += chunk.bytesize
		
		return chunk
	else
		chunk = @stream.finish
		
		@output_length += chunk.bytesize
		
		@stream.close
		
		return chunk.empty? ? nil : chunk
	end
end