hasType method
Checks if "content-type" equals with primaryType
and one of sub types.
To check exact content type: hasType('application', 'json')
Multiple sub type choices: hasType('application', 'json', 'geo+json')
This checks only primary type and sub type components of "content-type" header values.
Implementation
bool hasType(
String primaryType,
String subType0, [
String? orSubType1,
String? orSubType2,
String? orSubType3,
String? orSubType4,
]) {
if (mediaType.type == primaryType) {
final sub = mediaType.subtype;
if (sub == subType0) return true;
if (orSubType1 != null) {
if (sub == orSubType1) return true;
if (orSubType2 != null) {
if (sub == orSubType2) return true;
if (orSubType3 != null) {
if (sub == orSubType3) return true;
if (orSubType4 != null) {
if (sub == orSubType4) return true;
}
}
}
}
}
return false;
}