summaryrefslogtreecommitdiffstats
path: root/devtools/client/shared/curl.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/shared/curl.js')
-rw-r--r--devtools/client/shared/curl.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/devtools/client/shared/curl.js b/devtools/client/shared/curl.js
index 978cbad9c..420fe6aa5 100644
--- a/devtools/client/shared/curl.js
+++ b/devtools/client/shared/curl.js
@@ -76,7 +76,8 @@ const Curl = {
// Create post data.
let postData = [];
- if (utils.isUrlEncodedRequest(data) || data.method == "PUT") {
+ if (utils.isUrlEncodedRequest(data) ||
+ ["PUT", "POST", "PATCH"].includes(data.method)) {
postDataText = data.postDataText;
postData.push("--data");
postData.push(escapeString(utils.writePostDataTextParams(postDataText)));
@@ -107,7 +108,13 @@ const Curl = {
// Add http version.
if (data.httpVersion && data.httpVersion != DEFAULT_HTTP_VERSION) {
- command.push("--" + data.httpVersion.split("/")[1]);
+ let version = data.httpVersion.split("/")[1];
+ // curl accepts --http1.0, --http1.1 and --http2 for HTTP/1.0, HTTP/1.1
+ // and HTTP/2 protocols respectively. But the corresponding values in
+ // data.httpVersion are HTTP/1.0, HTTP/1.1 and HTTP/2.0
+ // So in case of HTTP/2.0 (which should ideally be HTTP/2) we are using
+ // only major version, and full version in other cases
+ command.push("--http" + (version == "2.0" ? version.split(".")[0] : version));
}
// Add request headers.
@@ -201,6 +208,9 @@ const CurlUtils = {
* Post data parameters.
*/
writePostDataTextParams: function (postDataText) {
+ if (!postDataText) {
+ return "";
+ }
let lines = postDataText.split("\r\n");
return lines[lines.length - 1];
},