Skip to content

Commit 1d70b9b

Browse files
committed
removing multi-part outputs until validaty is confirmed for each target translator
1 parent f941292 commit 1d70b9b

31 files changed

Lines changed: 46 additions & 156 deletions

‎src/targets/node/native.js‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ module.exports = function (options) {
5353

5454
code.push(opts.indent + 'res.on("end", function () {');
5555
code.push(opts.indent + opts.indent + 'var body = Buffer.concat(chunks);');
56+
code.push(opts.indent + opts.indent + 'console.log(body);');
5657
code.push(opts.indent + '});');
5758
code.push('});');
5859

@@ -62,12 +63,21 @@ module.exports = function (options) {
6263
code.push(util.format('req.write(%s);', JSON.stringify(this.source.postData.text)));
6364
}
6465

65-
if (!this.source.postData.text && this.source.postData.params) {
66-
var postData = this.source.postData.params.reduce(reducer, {});
66+
// if (!this.source.postData.text && this.source.postData.params) {
67+
// if (this.source.postData.mimeType === 'application/x-www-form-urlencoded') {
68+
// var postData = this.source.postData.params.reduce(reducer, {});
6769

68-
code.push(util.format('var postData = querystring.stringify(%s);', JSON.stringify(postData)));
69-
code.push(util.format('req.write(postData);'));
70-
}
70+
// code.push(util.format('var postData = querystring.stringify(%s);', JSON.stringify(postData)));
71+
// code.push(util.format('req.write(postData);'));
72+
// }
73+
74+
// if (this.source.postData.mimeType === 'multipart/form-data') {
75+
// var postData = this.source.postData.params.reduce(reducer, {});
76+
77+
// code.push(util.format('var postData = querystring.stringify(%s);', JSON.stringify(postData)));
78+
// code.push(util.format('req.write(postData);'));
79+
// }
80+
// }
7181

7282
code.push('req.end();');
7383

‎src/targets/wget.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ module.exports = function (options) {
3636
code.push('--body-data ' + JSON.stringify(this.source.postData.text));
3737
}
3838

39+
if (this.source.postData.mimeType === 'multipart/form-data') {
40+
this.source.postData.params.forEach(function (param) {
41+
if (param.value) {
42+
code.push(util.format('--body-data %s', JSON.stringify(param.value)));
43+
} else if (param.fileName) {
44+
code.push(util.format('--body-file "%s"', param.fileName));
45+
}
46+
});
47+
}
48+
3949
code.push(opts.short ? '-O' : '--output-document');
4050

4151
code.push(util.format('- "%s"', this.source.fullUrl));
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
curl --request POST \
22
--url "http://mockbin.com/har" \
33
--header "Content-Type: application/x-www-form-urlencoded" \
4-
--form "foo=bar" \
5-
--form "hello=world"
4+
--data "foo=bar&hello=world"

‎test/fixtures/output/curl/full.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ curl --request POST \
33
--header "Accept: application/json" \
44
--header "Content-Type: application/x-www-form-urlencoded" \
55
--cookie "foo=bar; bar=baz" \
6-
--form "foo=bar"
6+
--data "foo=bar"

‎test/fixtures/output/curl/multipart-file.sh‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎test/fixtures/output/curl/multipart-form-data.sh‎

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
http POST http://mockbin.com/har \
2-
Content-Type:application/x-www-form-urlencoded \
3-
foo:bar \
4-
hello:world
1+
echo "foo=bar&hello=world" | \
2+
http POST http://mockbin.com/har \
3+
Content-Type:application/x-www-form-urlencoded
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
http POST http://mockbin.com/har?baz=abc&foo=bar&foo=baz \
1+
echo "foo=bar" | \
2+
http POST http://mockbin.com/har?baz=abc&foo=bar&foo=baz \
23
Accept:application/json \
34
Content-Type:application/x-www-form-urlencoded \
4-
Cookie:foo=bar; bar=baz \
5-
foo:bar
5+
Cookie:foo=bar; bar=baz

‎test/fixtures/output/httpie/http1.sh‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎test/fixtures/output/httpie/multipart-file.sh‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)