[Requests] Add try_catch for utf8 decoding because dart really seems to have issues with json encoding and decoding. (also use camelCase)
Took 18 minutes
This commit is contained in:
parent
9f6bd740ca
commit
3c0fbf784f
|
@ -193,8 +193,13 @@ class MatrixApi {
|
|||
);
|
||||
break;
|
||||
}
|
||||
var resp_body = utf8.decode(resp.bodyBytes);
|
||||
var jsonString = String.fromCharCodes(resp_body.runes);
|
||||
var respBody = resp.body;
|
||||
try {
|
||||
respBody = utf8.decode(resp.bodyBytes);
|
||||
} catch (_) {
|
||||
// No-OP
|
||||
}
|
||||
var jsonString = String.fromCharCodes(respBody.runes);
|
||||
if (jsonString.startsWith('[') && jsonString.endsWith(']')) {
|
||||
jsonString = '\{"chunk":$jsonString\}';
|
||||
}
|
||||
|
|
|
@ -231,8 +231,13 @@ class Client {
|
|||
) async {
|
||||
final response = await http
|
||||
.get('https://${MatrixIdOrDomain.domain}/.well-known/matrix/client');
|
||||
var resp_body = utf8.decode(response.bodyBytes);
|
||||
final rawJson = json.decode(resp_body);
|
||||
var respBody = response.body;
|
||||
try {
|
||||
respBody = utf8.decode(response.bodyBytes);
|
||||
} catch (_) {
|
||||
// No-OP
|
||||
}
|
||||
final rawJson = json.decode(respBody);
|
||||
return WellKnownInformations.fromJson(rawJson);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue