fix: default Content-Type to x-www-form-urlencoded when importing curl POST with body (#5040)
fix: handle missing Content-Type when importing curl POST When importing a curl POST request with a body and no explicit Content-Type, default to `application/x-www-form-urlencoded` to match curl's behavior. Reference: https://everything.curl.dev/http/post/content-type.html
This commit is contained in:
parent
f929b8122b
commit
dafe56cfe9
1 changed files with 10 additions and 1 deletions
|
|
@ -132,7 +132,16 @@ export const parseCurlCommand = (curlCommand: string) => {
|
|||
danglingParams = [...danglingParams, ...newQueries.danglingParams]
|
||||
hasBodyBeenParsed = true
|
||||
} else if (
|
||||
rawContentType.includes("application/x-www-form-urlencoded") &&
|
||||
(rawContentType.includes("application/x-www-form-urlencoded") ||
|
||||
/**
|
||||
* When using the -d option with curl for a POST operation,
|
||||
* curl includes a default header: Content-Type: application/x-www-form-urlencoded.
|
||||
* https://everything.curl.dev/http/post/content-type.html
|
||||
*/
|
||||
(!rawContentType &&
|
||||
method === "POST" &&
|
||||
rawData &&
|
||||
rawData.length > 0)) &&
|
||||
!!pairs &&
|
||||
Array.isArray(rawData)
|
||||
) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue