class Rack::Deflater

def should_deflate?(env, status, headers, body)

Whether the body should be compressed.
def should_deflate?(env, status, headers, body)
  # Skip compressing empty entity body responses and responses with
  # no-transform set.
  if Utils::STATUS_WITH_NO_ENTITY_BODY.key?(status.to_i) ||
      /\bno-transform\b/.match?(headers[CACHE_CONTROL].to_s) ||
      headers['content-encoding']&.!~(/\bidentity\b/)
    return false
  end
  # Skip if @compressible_types are given and does not include request's content type
  return false if @compressible_types && !(headers.has_key?(CONTENT_TYPE) && @compressible_types.include?(headers[CONTENT_TYPE][/[^;]*/]))
  # Skip if @condition lambda is given and evaluates to false
  return false if @condition && !@condition.call(env, status, headers, body)
  # No point in compressing empty body, also handles usage with
  # Rack::Sendfile.
  return false if headers[CONTENT_LENGTH] == '0'
  true
end