mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
Update content_type_utils.dart
This commit is contained in:
@ -7,15 +7,7 @@ ContentType? getContentTypeFromHeadersMap(
|
||||
) {
|
||||
if (kvMap != null && kvMap.hasKeyContentType()) {
|
||||
var val = getMediaTypeFromHeaders(kvMap);
|
||||
if (val != null) {
|
||||
if (val.subtype.contains(kSubTypeJson)) {
|
||||
return ContentType.json;
|
||||
} else if (val.type == kTypeMultipart &&
|
||||
val.subtype == kSubTypeFormData) {
|
||||
return ContentType.formdata;
|
||||
}
|
||||
return ContentType.text;
|
||||
}
|
||||
return getContentTypeFromMediaType(val);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -37,3 +29,26 @@ MediaType? getMediaTypeFromContentType(String? contentType) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
ContentType? getContentTypeFromMediaType(MediaType? mediaType) {
|
||||
if (mediaType != null) {
|
||||
if (mediaType.subtype.contains(kSubTypeJson)) {
|
||||
return ContentType.json;
|
||||
} else if (mediaType.type == kTypeMultipart &&
|
||||
mediaType.subtype == kSubTypeFormData) {
|
||||
return ContentType.formdata;
|
||||
}
|
||||
return ContentType.text;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
ContentType? getContentTypeFromContentTypeStr(
|
||||
String? contentType,
|
||||
) {
|
||||
if (contentType != null) {
|
||||
var val = getMediaTypeFromContentType(contentType);
|
||||
return getContentTypeFromMediaType(val);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user