HttpBody.fromString constructor
HttpBody.fromString(})
Construct the body to an HTTP request or an HTTP response from text.
If encoding
is given, it will be used to encode/decode the body.
Otherwise, the charset
parameter from contentType
will be mapped to an
Encoding supported by Dart.
If a charset
parameter is not available or the value is unrecognized,
fallbackEncoding
will be used.
If fallbackEncoding
is null
, utf-8 will be the default encoding.
If an encoding cannot be parsed from the content-type header (via the
charset
param), then fallbackEncoding
will be used (utf-8 by default).
Implementation
HttpBody.fromString(this.contentType, String? body,
{Encoding? encoding, Encoding? fallbackEncoding})
: _encoding =
encoding ?? http_utils.parseEncodingFromContentType(contentType),
_fallbackEncoding = fallbackEncoding ?? utf8,
_body = body ?? '';