From a17200522d04583af42bbed1c9e3a8ed27e1cf71 Mon Sep 17 00:00:00 2001 From: wanghongenpin Date: Sun, 15 Sep 2024 22:57:16 +0800 Subject: [PATCH] mediaType default charset --- lib/network/http/content_type.dart | 7 +++++-- lib/network/http/http.dart | 2 +- linux/build.sh | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/network/http/content_type.dart b/lib/network/http/content_type.dart index 956c3fc..202fe95 100644 --- a/lib/network/http/content_type.dart +++ b/lib/network/http/content_type.dart @@ -49,6 +49,8 @@ class MediaType { static List defaultCharsetMediaTypes = [ MediaType("text", "plain", charset: "utf-8"), MediaType("text", "html", charset: "utf-8"), + MediaType("text", "javascript", charset: "utf-8"), + MediaType("text", "css", charset: "utf-8"), MediaType("application", "json", charset: "utf-8"), MediaType("application", "problem+json", charset: "utf-8"), MediaType("application", "xml", charset: "utf-8"), @@ -61,9 +63,10 @@ class MediaType { final String subtype; final Map parameters; - MediaType(this.type, this.subtype, {this.parameters = const {}, String? charset}) { + MediaType(this.type, this.subtype, {Map? parameters, String? charset}) + : parameters = parameters ?? {} { if (charset != null) { - parameters["charset"] = charset; + this.parameters["charset"] = charset; } } diff --git a/lib/network/http/http.dart b/lib/network/http/http.dart index 367eb2d..947744b 100644 --- a/lib/network/http/http.dart +++ b/lib/network/http/http.dart @@ -83,7 +83,7 @@ abstract class HttpMessage { String? get charset { var contentType = headers.contentType; if (contentType.isEmpty) { - return null; + return 'utf-8'; } MediaType mediaType = MediaType.valueOf(contentType); diff --git a/linux/build.sh b/linux/build.sh index bc4a262..f95b290 100644 --- a/linux/build.sh +++ b/linux/build.sh @@ -1,5 +1,6 @@ #!/bin/bash + pwd cd ../build/linux/x64/release rm -rf package