setAllowsCompression method Null safety

void setAllowsCompression(
  1. ContentType contentType,
  2. bool allowed
)

Toggles whether HTTP bodies of contentType are compressed with GZIP.

Use this method when wanting to compress a Response.body, but there is no need for a Codec to transform the body object.

Implementation

void setAllowsCompression(ContentType contentType, bool allowed) {
  if (contentType.subType == "*") {
    _primaryTypeCompressionMap[contentType.primaryType] = allowed;
  } else {
    final innerCompress =
        _fullySpecifiedCompressionMap[contentType.primaryType] ?? {};
    innerCompress[contentType.subType] = allowed;
    _fullySpecifiedCompressionMap[contentType.primaryType] = innerCompress;
  }
}