зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1353535 - Fix "copy as curl" POST request without json data. r=gasolin
--HG-- extra : rebase_source : 35d42a108df7e2241f8b0740a6ca8bc3997bdf13
This commit is contained in:
Родитель
19d640cfe8
Коммит
18fa48d27c
|
@ -41,6 +41,7 @@ add_task(function* () {
|
||||||
data = yield createCurlData(requests.post, getLongString);
|
data = yield createCurlData(requests.post, getLongString);
|
||||||
testIsUrlEncodedRequest(data);
|
testIsUrlEncodedRequest(data);
|
||||||
testWritePostDataTextParams(data);
|
testWritePostDataTextParams(data);
|
||||||
|
testWriteEmptyPostDataTextParams(data);
|
||||||
testDataArgumentOnGeneratedCommand(data);
|
testDataArgumentOnGeneratedCommand(data);
|
||||||
|
|
||||||
data = yield createCurlData(requests.multipart, getLongString);
|
data = yield createCurlData(requests.multipart, getLongString);
|
||||||
|
@ -103,6 +104,12 @@ function testWritePostDataTextParams(data) {
|
||||||
"Should return a serialized representation of the request parameters");
|
"Should return a serialized representation of the request parameters");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testWriteEmptyPostDataTextParams(data) {
|
||||||
|
let params = CurlUtils.writePostDataTextParams(null);
|
||||||
|
is(params, "",
|
||||||
|
"Should return a empty string when no parameters provided");
|
||||||
|
}
|
||||||
|
|
||||||
function testDataArgumentOnGeneratedCommand(data) {
|
function testDataArgumentOnGeneratedCommand(data) {
|
||||||
let curlCommand = Curl.generateCommand(data);
|
let curlCommand = Curl.generateCommand(data);
|
||||||
ok(curlCommand.includes("--data"),
|
ok(curlCommand.includes("--data"),
|
||||||
|
|
|
@ -202,6 +202,9 @@ const CurlUtils = {
|
||||||
* Post data parameters.
|
* Post data parameters.
|
||||||
*/
|
*/
|
||||||
writePostDataTextParams: function (postDataText) {
|
writePostDataTextParams: function (postDataText) {
|
||||||
|
if (!postDataText) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
let lines = postDataText.split("\r\n");
|
let lines = postDataText.split("\r\n");
|
||||||
return lines[lines.length - 1];
|
return lines[lines.length - 1];
|
||||||
},
|
},
|
||||||
|
|
Загрузка…
Ссылка в новой задаче