mediaType default charset

This commit is contained in:
wanghongenpin
2024-09-15 22:57:16 +08:00
parent a6078e53c7
commit a17200522d
3 changed files with 7 additions and 3 deletions

View File

@@ -49,6 +49,8 @@ class MediaType {
static List<MediaType> 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<String, String> parameters;
MediaType(this.type, this.subtype, {this.parameters = const {}, String? charset}) {
MediaType(this.type, this.subtype, {Map<String, String>? parameters, String? charset})
: parameters = parameters ?? {} {
if (charset != null) {
parameters["charset"] = charset;
this.parameters["charset"] = charset;
}
}

View File

@@ -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);

View File

@@ -1,5 +1,6 @@
#!/bin/bash
pwd
cd ../build/linux/x64/release
rm -rf package