Add empty data param to cURL if no POST request body was given (#6017)

* Add empty data param to cURL if no request body was given

Some middleware applications do not allow POST requests without a content-length header. By adding a empty data parameter to the curl command, the content-length header will be set by curl. Besides this it is more obvious to the user that no request body is sent.

* use double quotes like the rest of the curl command
This commit is contained in:
mircohaug
2020-05-30 00:10:22 +02:00
committed by GitHub
parent 28b7d7c548
commit eaca2f6fd8
2 changed files with 16 additions and 2 deletions

View File

@@ -47,6 +47,9 @@ export default function curl( request ){
curlified.push( "-d" )
curlified.push( JSON.stringify( request.get("body") ).replace(/\\n/g, "") )
}
} else if(!request.get("body") && request.get("method") === "POST") {
curlified.push( "-d" )
curlified.push( "\"\"" )
}
return curlified.join( " " )