From ec2f6bc907e7ba154c01ae5762aafe258ba34f9e Mon Sep 17 00:00:00 2001 From: Tibor Bossanyi Date: Sun, 2 Apr 2023 11:45:09 +0200 Subject: [PATCH] v1.0.24 http utf8 --- README.md | 4 ++++ lib/service/webapi.dart | 27 ++++++++++++++++++--------- pubspec.yaml | 2 +- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 4657437..6f815bf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ Workout Test and Diet 4 You Common Util Functions +### Version 1.0.24 + +http get utf8 + ### Version 1.0.23 webapi CORS solution with the API diff --git a/lib/service/webapi.dart b/lib/service/webapi.dart index a0f09be..85fcc14 100644 --- a/lib/service/webapi.dart +++ b/lib/service/webapi.dart @@ -63,10 +63,15 @@ class APIWebClient with Common, Logging { Cache().authToken = authToken; } var uri = Uri.parse(url); - var result = await http.post(uri, body: body, headers: { - "Content-Type": "application/json", - "Authorization": 'Bearer $authToken', - }); + var result = await http.post( + uri, + body: body, + headers: { + "Content-Type": "application/json", + "Authorization": 'Bearer $authToken', + "charset": "UTF-8", + }, + ); log(" ------------post response code: ${result.statusCode}"); if (result.statusCode == 200) { return result.body; @@ -95,14 +100,18 @@ class APIWebClient with Common, Logging { Cache().authToken = authToken; } var uri = Uri.parse(url); - var result = await http.get(uri, headers: { - "Content-Type": "application/json", - "Authorization": 'Bearer $authToken', - }); + var result = await http.get( + uri, + headers: { + "Content-Type": "application/json", + "Authorization": 'Bearer $authToken', + "charset": "UTF-8", + }, + ); log(" ------------get response code: ${result.statusCode}"); if (result.statusCode == 200) { - return result.body; + return utf8.decode(result.bodyBytes); } else if (result.statusCode == 404) { throw const NotFoundException(message: "Not Found"); } else { diff --git a/pubspec.yaml b/pubspec.yaml index b323cda..b304a8f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: workouttest_util description: Workout Test app and web functions. -version: 1.0.23 +version: 1.0.24 environment: sdk: ">=2.18.6 <3.0.0"