class Async::HTTP::Body::Deflate

def self.for(body, window_size = GZIP, level = DEFAULT_LEVEL)

def self.for(body, window_size = GZIP, level = DEFAULT_LEVEL)
	self.new(body, Zlib::Deflate.new(level, window_size))
end

def read

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