detect presence of request body

This commit is contained in:
Ankit Mahato
2025-11-17 06:26:03 +05:30
parent 68c8e9ed63
commit e5f653daf9

View File

@@ -47,6 +47,10 @@ class HttpRequestModel with _$HttpRequestModel {
bool get hasTextContentType => bodyContentType == ContentType.text;
int get contentLength => utf8.encode(body ?? "").length;
bool get hasBody => hasJsonData || hasTextData || hasFormData;
bool get hasAnyBody =>
(hasJsonContentType && contentLength > 0) ||
(hasTextContentType && contentLength > 0) ||
(hasFormDataContentType && formDataMapList.isNotEmpty);
bool get hasJsonData =>
kMethodsWithBody.contains(method) &&
hasJsonContentType &&