ResponseBuffered constructor

ResponseBuffered(
  1. ContentType ct, {
  2. Encoding? encoding,
})

Constructor

The body of the HTTP response will be encoded using encoding (utf8 by default).

If the content type ct has a character set, it must match the encoding.

Implementation

ResponseBuffered(ContentType ct, {Encoding? encoding})
    : _encoding = encoding ?? _defaultEncoding {
  // Check content type's character set is compatible with the encoding

  if (ct.charset != null && ct.charset != _encoding.name) {
    throw ArgumentError.value(ct, 'ct',
        'character set "${ct.charset}" != encoding "${_encoding.name}"');
  }

  contentType = ct;
}