setAllowsCompression method

void setAllowsCompression (ContentType contentType, 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.


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