decodeBodyBytes function
Returns the decoded body by utf-8 if application/json with the given headers. Else, returns the decoded body by default algorithm of dart:http. Because avoid to text garbling when header only contains 'application/json' without '; charset=utf-8'.
Implementation
Future<String?> decodeBodyBytes(Stream<List<int>> body) async {
try {
return await utf8.decodeStream(body);
} catch (e, s) {
openapiLogger.warning("Cannot decode body", e, s);
return null;
}
}