summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <wolfbeast@users.noreply.github.com>2017-11-18 14:45:48 +0100
committerGitHub <noreply@github.com>2017-11-18 14:45:48 +0100
commitaa9d16c922b86e730144a209d0be0481f6bfe850 (patch)
treeab6fa8960622606c225b75b9ecce9d2a421429d4
parentd875128c0a02eff4dc7fabed4ff5990059ff6fe4 (diff)
parentcbc57c6c55267e64331ca6412b971438063c7853 (diff)
downloadpalemoon-gre-aa9d16c922b86e730144a209d0be0481f6bfe850.tar.gz
Merge pull request #1472 from janekptacijarabaci/devtools_network_curl_2
DevTools - network - Copy as cURL (POST)
-rw-r--r--toolkit/devtools/netmonitor/test/browser_net_curl-utils.js14
-rw-r--r--toolkit/devtools/shared/Curl.jsm6
2 files changed, 19 insertions, 1 deletions
diff --git a/toolkit/devtools/netmonitor/test/browser_net_curl-utils.js b/toolkit/devtools/netmonitor/test/browser_net_curl-utils.js
index cbb438912..e4d5e2a85 100644
--- a/toolkit/devtools/netmonitor/test/browser_net_curl-utils.js
+++ b/toolkit/devtools/netmonitor/test/browser_net_curl-utils.js
@@ -30,6 +30,8 @@ function test() {
yield createCurlData(requests.post.attachment, gNetwork).then((aData) => {
test_isUrlEncodedRequest(aData);
test_writePostDataTextParams(aData);
+ test_writeEmptyPostDataTextParams(aData);
+ test_dataArgumentOnGeneratedCommand(aData);
});
yield createCurlData(requests.multipart.attachment, gNetwork).then((aData) => {
@@ -86,6 +88,18 @@ function test_writePostDataTextParams(aData) {
"Should return a serialized representation of the request parameters");
}
+function test_writeEmptyPostDataTextParams(aData) {
+ let params = CurlUtils.writePostDataTextParams(null);
+ is(params, "",
+ "Should return a empty string when no parameters provided");
+}
+
+function test_dataArgumentOnGeneratedCommand(aData) {
+ let curlCommand = Curl.generateCommand(aData);
+ ok(curlCommand.includes("--data"),
+ "Should return a curl command with --data");
+}
+
function test_getMultipartBoundary(aData) {
let boundary = CurlUtils.getMultipartBoundary(aData);
ok(/-{3,}\w+/.test(boundary),
diff --git a/toolkit/devtools/shared/Curl.jsm b/toolkit/devtools/shared/Curl.jsm
index 76d6efeae..35dc6d982 100644
--- a/toolkit/devtools/shared/Curl.jsm
+++ b/toolkit/devtools/shared/Curl.jsm
@@ -78,7 +78,8 @@ this.Curl = {
// Create post data.
let data = [];
- if (utils.isUrlEncodedRequest(aData) || aData.method == "PUT") {
+ if (utils.isUrlEncodedRequest(aData) ||
+ ["PUT", "POST"].includes(aData.method)) {
postDataText = aData.postDataText;
data.push("--data");
data.push(escapeString(utils.writePostDataTextParams(postDataText)));
@@ -207,6 +208,9 @@ this.CurlUtils = {
* Post data parameters.
*/
writePostDataTextParams: function(aPostDataText) {
+ if (!aPostDataText) {
+ return "";
+ }
let lines = aPostDataText.split("\r\n");
return lines[lines.length - 1];
},