encoding property
Encoding
get
encoding
The encoding used for the request.
This encoding is used when converting between bodyBytes and body.
If the request has a Content-Type
header and that header has a charset
parameter, that parameter's value is used as the encoding. Otherwise, if
encoding has been set manually, that encoding is used. If that hasn't
been set either, this defaults to utf8.
If the charset
parameter's value is not a known Encoding, reading this
will throw a FormatException.
If the request has a Content-Type
header, setting this will set the
charset parameter on that header.
Implementation
Encoding get encoding {
if (_contentType == null ||
!_contentType!.parameters.containsKey('charset')) {
return _defaultEncoding;
}
return requiredEncodingForCharset(_contentType!.parameters['charset']!);
}
set
encoding
(Encoding value)
Implementation
set encoding(Encoding value) {
_checkFinalized();
_defaultEncoding = value;
var contentType = _contentType;
if (contentType == null) return;
_contentType = contentType.change(parameters: {'charset': value.name});
}