Added form-data and contentType from the Curl parser that got updated

This commit is contained in:
Pratham
2024-11-30 18:32:16 +05:30
parent 6dcdb49b62
commit 080a4e35f0

View File

@ -23,16 +23,29 @@ class CurlFileImport {
))
.toList();
// TODO: parse curl data to determine the type of body
final body = curl.data;
final formData = curl.formData;
// Determine content type based on form data and headers
final bool hasJsonContentType = headers?.any((header) =>
header.name == "Content-Type" &&
header.value == "application/json") ??
false;
final ContentType contentType = curl.form
? ContentType.formdata
: hasJsonContentType
? ContentType.json
: ContentType.text;
return HttpRequestModel(
method: method,
url: url,
headers: headers,
params: params,
body: body,
);
method: method,
url: url,
headers: headers,
params: params,
body: body,
bodyContentType: contentType,
formData: formData);
} catch (e) {
return null;
}