v1.0.24 http utf8

This commit is contained in:
Tibor Bossanyi 2023-04-02 11:45:09 +02:00
parent 9311a888bc
commit ec2f6bc907
3 changed files with 23 additions and 10 deletions

View File

@ -1,5 +1,9 @@
Workout Test and Diet 4 You Common Util Functions Workout Test and Diet 4 You Common Util Functions
### Version 1.0.24
http get utf8
### Version 1.0.23 ### Version 1.0.23
webapi CORS solution with the API webapi CORS solution with the API

View File

@ -63,10 +63,15 @@ class APIWebClient with Common, Logging {
Cache().authToken = authToken; Cache().authToken = authToken;
} }
var uri = Uri.parse(url); var uri = Uri.parse(url);
var result = await http.post(uri, body: body, headers: { var result = await http.post(
uri,
body: body,
headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": 'Bearer $authToken', "Authorization": 'Bearer $authToken',
}); "charset": "UTF-8",
},
);
log(" ------------post response code: ${result.statusCode}"); log(" ------------post response code: ${result.statusCode}");
if (result.statusCode == 200) { if (result.statusCode == 200) {
return result.body; return result.body;
@ -95,14 +100,18 @@ class APIWebClient with Common, Logging {
Cache().authToken = authToken; Cache().authToken = authToken;
} }
var uri = Uri.parse(url); var uri = Uri.parse(url);
var result = await http.get(uri, headers: { var result = await http.get(
uri,
headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": 'Bearer $authToken', "Authorization": 'Bearer $authToken',
}); "charset": "UTF-8",
},
);
log(" ------------get response code: ${result.statusCode}"); log(" ------------get response code: ${result.statusCode}");
if (result.statusCode == 200) { if (result.statusCode == 200) {
return result.body; return utf8.decode(result.bodyBytes);
} else if (result.statusCode == 404) { } else if (result.statusCode == 404) {
throw const NotFoundException(message: "Not Found"); throw const NotFoundException(message: "Not Found");
} else { } else {

View File

@ -1,6 +1,6 @@
name: workouttest_util name: workouttest_util
description: Workout Test app and web functions. description: Workout Test app and web functions.
version: 1.0.23 version: 1.0.24
environment: environment:
sdk: ">=2.18.6 <3.0.0" sdk: ">=2.18.6 <3.0.0"