mirror of
https://github.com/foss42/apidash.git
synced 2025-06-02 16:02:12 +08:00
Added form-data and contentType from the Curl parser that got updated
This commit is contained in:
@ -23,16 +23,29 @@ class CurlFileImport {
|
|||||||
))
|
))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
// TODO: parse curl data to determine the type of body
|
|
||||||
final body = curl.data;
|
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(
|
return HttpRequestModel(
|
||||||
method: method,
|
method: method,
|
||||||
url: url,
|
url: url,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
params: params,
|
params: params,
|
||||||
body: body,
|
body: body,
|
||||||
);
|
bodyContentType: contentType,
|
||||||
|
formData: formData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user