@readme/httpsnippet 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/index.js +1 -1
- package/src/targets/clojure/clj_http.js +13 -11
- package/src/targets/javascript/axios.js +12 -10
- package/src/targets/javascript/fetch.js +16 -12
- package/src/targets/javascript/jquery.js +20 -18
- package/src/targets/javascript/xhr.js +19 -17
- package/src/targets/node/fetch.js +25 -19
- package/src/targets/node/request.js +29 -27
- package/src/targets/node/unirest.js +19 -17
- package/src/targets/php/guzzle.js +30 -28
- package/src/targets/php/helpers.js +0 -2
- package/src/targets/php/http2.js +33 -31
- package/src/targets/shell/curl.js +11 -9
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.0.
|
|
2
|
+
"version": "3.0.1",
|
|
3
3
|
"name": "@readme/httpsnippet",
|
|
4
4
|
"description": "HTTP Request snippet generator for *most* languages",
|
|
5
5
|
"homepage": "https://github.com/readmeio/httpsnippet",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"test": "jest --coverage"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@readme/eslint-config": "^
|
|
57
|
-
"eslint": "^
|
|
56
|
+
"@readme/eslint-config": "^8.0.2",
|
|
57
|
+
"eslint": "^8.3.0",
|
|
58
58
|
"glob": "^7.1.7",
|
|
59
59
|
"jest": "^27.2.0",
|
|
60
|
-
"prettier": "^2.
|
|
60
|
+
"prettier": "^2.5.0",
|
|
61
61
|
"require-directory": "^2.1.1"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
package/src/index.js
CHANGED
|
@@ -7,7 +7,7 @@ const targets = require('./targets');
|
|
|
7
7
|
const url = require('url');
|
|
8
8
|
const validate = require('har-validator/lib/async');
|
|
9
9
|
|
|
10
|
-
const { formDataIterator, isBlob } = require('./helpers/form-data
|
|
10
|
+
const { formDataIterator, isBlob } = require('./helpers/form-data');
|
|
11
11
|
|
|
12
12
|
// constructor
|
|
13
13
|
const HTTPSnippet = function (data, opts = {}) {
|
|
@@ -128,20 +128,22 @@ module.exports = function (source, options) {
|
|
|
128
128
|
delete params.headers[helpers.getHeaderName(params.headers, 'content-type')];
|
|
129
129
|
break;
|
|
130
130
|
case 'multipart/form-data':
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
if (source.postData.params) {
|
|
132
|
+
params.multipart = source.postData.params.map(function (x) {
|
|
133
|
+
if (x.fileName && !x.value) {
|
|
134
|
+
return {
|
|
135
|
+
name: x.name,
|
|
136
|
+
content: new File(x.fileName),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
133
140
|
return {
|
|
134
141
|
name: x.name,
|
|
135
|
-
content:
|
|
142
|
+
content: x.value,
|
|
136
143
|
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
name: x.name,
|
|
141
|
-
content: x.value,
|
|
142
|
-
};
|
|
143
|
-
});
|
|
144
|
-
delete params.headers[helpers.getHeaderName(params.headers, 'content-type')];
|
|
144
|
+
});
|
|
145
|
+
delete params.headers[helpers.getHeaderName(params.headers, 'content-type')];
|
|
146
|
+
}
|
|
145
147
|
break;
|
|
146
148
|
}
|
|
147
149
|
|
|
@@ -46,19 +46,21 @@ module.exports = function (source, options) {
|
|
|
46
46
|
break;
|
|
47
47
|
|
|
48
48
|
case 'multipart/form-data':
|
|
49
|
-
|
|
49
|
+
if (source.postData.params) {
|
|
50
|
+
code.push('const form = new FormData();');
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
source.postData.params.forEach(function (param) {
|
|
53
|
+
code.push(
|
|
54
|
+
'form.append(%s, %s);',
|
|
55
|
+
JSON.stringify(param.name),
|
|
56
|
+
JSON.stringify(param.value || param.fileName || '')
|
|
57
|
+
);
|
|
58
|
+
});
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
code.blank();
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
reqOpts.data = '[form]';
|
|
63
|
+
}
|
|
62
64
|
break;
|
|
63
65
|
|
|
64
66
|
default:
|
|
@@ -44,17 +44,19 @@ module.exports = function (source, options) {
|
|
|
44
44
|
break;
|
|
45
45
|
|
|
46
46
|
case 'multipart/form-data':
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
47
|
+
if (source.postData.params) {
|
|
48
|
+
code.push('const form = new FormData();');
|
|
49
|
+
|
|
50
|
+
source.postData.params.forEach(function (param) {
|
|
51
|
+
code.push(
|
|
52
|
+
'form.append(%s, %s);',
|
|
53
|
+
JSON.stringify(param.name),
|
|
54
|
+
JSON.stringify(param.value || param.fileName || '')
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
code.blank();
|
|
59
|
+
}
|
|
58
60
|
break;
|
|
59
61
|
|
|
60
62
|
default:
|
|
@@ -89,7 +91,9 @@ module.exports = function (source, options) {
|
|
|
89
91
|
.blank();
|
|
90
92
|
|
|
91
93
|
if (source.postData.mimeType === 'multipart/form-data') {
|
|
92
|
-
|
|
94
|
+
if (source.postData.params) {
|
|
95
|
+
code.push('options.body = form;').blank();
|
|
96
|
+
}
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
code
|
|
@@ -38,29 +38,31 @@ module.exports = function (source, options) {
|
|
|
38
38
|
break;
|
|
39
39
|
|
|
40
40
|
case 'multipart/form-data':
|
|
41
|
-
|
|
41
|
+
if (source.postData.params) {
|
|
42
|
+
code.push('const form = new FormData();');
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
source.postData.params.forEach(function (param) {
|
|
45
|
+
code.push(
|
|
46
|
+
'form.append(%s, %s);',
|
|
47
|
+
JSON.stringify(param.name),
|
|
48
|
+
JSON.stringify(param.value || param.fileName || '')
|
|
49
|
+
);
|
|
50
|
+
});
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
settings.processData = false;
|
|
53
|
+
settings.contentType = false;
|
|
54
|
+
settings.mimeType = 'multipart/form-data';
|
|
55
|
+
settings.data = '[form]';
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
// remove the contentType header
|
|
58
|
+
if (helpers.hasHeader(settings.headers, 'content-type')) {
|
|
59
|
+
if (helpers.getHeader(settings.headers, 'content-type').indexOf('boundary')) {
|
|
60
|
+
delete settings.headers[helpers.getHeaderName(settings.headers, 'content-type')];
|
|
61
|
+
}
|
|
60
62
|
}
|
|
61
|
-
}
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
code.blank();
|
|
65
|
+
}
|
|
64
66
|
break;
|
|
65
67
|
|
|
66
68
|
default:
|
|
@@ -26,25 +26,27 @@ module.exports = function (source, options) {
|
|
|
26
26
|
break;
|
|
27
27
|
|
|
28
28
|
case 'multipart/form-data':
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (helpers.
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
if (source.postData.params) {
|
|
30
|
+
code.push('const data = new FormData();');
|
|
31
|
+
|
|
32
|
+
source.postData.params.forEach(function (param) {
|
|
33
|
+
code.push(
|
|
34
|
+
'data.append(%s, %s);',
|
|
35
|
+
JSON.stringify(param.name),
|
|
36
|
+
JSON.stringify(param.value || param.fileName || '')
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// remove the contentType header
|
|
41
|
+
if (helpers.hasHeader(source.allHeaders, 'content-type')) {
|
|
42
|
+
if (helpers.getHeader(source.allHeaders, 'content-type').indexOf('boundary')) {
|
|
43
|
+
// eslint-disable-next-line no-param-reassign
|
|
44
|
+
delete source.allHeaders[helpers.getHeaderName(source.allHeaders, 'content-type')];
|
|
45
|
+
}
|
|
44
46
|
}
|
|
45
|
-
}
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
code.blank();
|
|
49
|
+
}
|
|
48
50
|
break;
|
|
49
51
|
|
|
50
52
|
default:
|
|
@@ -30,10 +30,12 @@ module.exports = function (source, options) {
|
|
|
30
30
|
// The `form-data` library automatically adds a `Content-Type` header for `multipart/form-data` content and if we
|
|
31
31
|
// add our own here, data won't be correctly transferred.
|
|
32
32
|
if (source.postData.mimeType === 'multipart/form-data') {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
if (source.postData.params) {
|
|
34
|
+
const contentTypeHeader = headerHelpers.getHeaderName(source.allHeaders, 'content-type');
|
|
35
|
+
if (contentTypeHeader) {
|
|
36
|
+
// eslint-disable-next-line no-param-reassign
|
|
37
|
+
delete source.allHeaders[contentTypeHeader];
|
|
38
|
+
}
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
|
|
@@ -61,21 +63,23 @@ module.exports = function (source, options) {
|
|
|
61
63
|
break;
|
|
62
64
|
|
|
63
65
|
case 'multipart/form-data':
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
if (source.postData.params) {
|
|
67
|
+
code.unshift("const FormData = require('form-data');");
|
|
68
|
+
code.push('const formData = new FormData();');
|
|
69
|
+
code.blank();
|
|
70
|
+
|
|
71
|
+
source.postData.params.forEach(function (param) {
|
|
72
|
+
if (!param.fileName && !param.contentType) {
|
|
73
|
+
code.push(`formData.append('${param.name}', '${param.value}');`);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
67
76
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (param.fileName) {
|
|
75
|
-
includeFS = true;
|
|
76
|
-
code.push(`formData.append('${param.name}', fs.createReadStream('${param.fileName}'));`);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
77
|
+
if (param.fileName) {
|
|
78
|
+
includeFS = true;
|
|
79
|
+
code.push(`formData.append('${param.name}', fs.createReadStream('${param.fileName}'));`);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
79
83
|
break;
|
|
80
84
|
|
|
81
85
|
default:
|
|
@@ -112,7 +116,9 @@ module.exports = function (source, options) {
|
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
if (source.postData.mimeType === 'multipart/form-data') {
|
|
115
|
-
|
|
119
|
+
if (source.postData.params) {
|
|
120
|
+
code.push('options.body = formData;').blank();
|
|
121
|
+
}
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
code
|
|
@@ -44,33 +44,35 @@ module.exports = function (source, options) {
|
|
|
44
44
|
break;
|
|
45
45
|
|
|
46
46
|
case 'multipart/form-data':
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
47
|
+
if (source.postData.params) {
|
|
48
|
+
reqOpts.formData = {};
|
|
49
|
+
|
|
50
|
+
source.postData.params.forEach(function (param) {
|
|
51
|
+
const attachment = {};
|
|
52
|
+
|
|
53
|
+
if (!param.fileName && !param.contentType) {
|
|
54
|
+
reqOpts.formData[param.name] = param.value;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (param.fileName) {
|
|
59
|
+
includeFS = true;
|
|
60
|
+
|
|
61
|
+
attachment.value = `fs.createReadStream("${param.fileName}")`;
|
|
62
|
+
} else if (param.value) {
|
|
63
|
+
attachment.value = param.value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (param.fileName) {
|
|
67
|
+
attachment.options = {
|
|
68
|
+
filename: param.fileName,
|
|
69
|
+
contentType: param.contentType ? param.contentType : null,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
reqOpts.formData[param.name] = attachment;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
74
76
|
break;
|
|
75
77
|
|
|
76
78
|
default:
|
|
@@ -63,29 +63,31 @@ module.exports = function (source, options) {
|
|
|
63
63
|
break;
|
|
64
64
|
|
|
65
65
|
case 'multipart/form-data': {
|
|
66
|
-
|
|
66
|
+
if (source.postData.params) {
|
|
67
|
+
const multipart = [];
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
source.postData.params.forEach(function (param) {
|
|
70
|
+
const part = {};
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
if (param.fileName && !param.value) {
|
|
73
|
+
includeFS = true;
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (part.body) {
|
|
80
|
-
if (param.contentType) {
|
|
81
|
-
part['content-type'] = param.contentType;
|
|
75
|
+
part.body = `fs.createReadStream("${param.fileName}")`;
|
|
76
|
+
} else if (param.value) {
|
|
77
|
+
part.body = param.value;
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
if (part.body) {
|
|
81
|
+
if (param.contentType) {
|
|
82
|
+
part['content-type'] = param.contentType;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
multipart.push(part);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
87
88
|
|
|
88
|
-
|
|
89
|
+
code.push('req.multipart(%s);', JSON.stringify(multipart, null, opts.indent)).blank();
|
|
90
|
+
}
|
|
89
91
|
break;
|
|
90
92
|
}
|
|
91
93
|
|
|
@@ -42,38 +42,40 @@ module.exports = function (source, options) {
|
|
|
42
42
|
break;
|
|
43
43
|
|
|
44
44
|
case 'multipart/form-data': {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
if (source.postData.params) {
|
|
46
|
+
const fields = [];
|
|
47
|
+
|
|
48
|
+
source.postData.params.forEach(function (param) {
|
|
49
|
+
if (param.fileName) {
|
|
50
|
+
const field = {
|
|
51
|
+
name: param.name,
|
|
52
|
+
filename: param.fileName,
|
|
53
|
+
contents: param.value,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
if (param.contentType) {
|
|
57
|
+
field.headers = { 'Content-Type': param.contentType };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
fields.push(field);
|
|
61
|
+
} else if (param.value) {
|
|
62
|
+
fields.push({
|
|
63
|
+
name: param.name,
|
|
64
|
+
contents: param.value,
|
|
65
|
+
});
|
|
57
66
|
}
|
|
67
|
+
});
|
|
58
68
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
fields.push({
|
|
62
|
-
name: param.name,
|
|
63
|
-
contents: param.value,
|
|
64
|
-
});
|
|
69
|
+
if (fields.length) {
|
|
70
|
+
requestOptions.push(1, "'multipart' => %s", helpers.convert(fields, opts.indent + opts.indent, opts.indent));
|
|
65
71
|
}
|
|
66
|
-
});
|
|
67
72
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (headerHelpers.getHeader(source.headersObj, 'content-type').includes('boundary')) {
|
|
75
|
-
// eslint-disable-next-line no-param-reassign
|
|
76
|
-
delete source.headersObj[headerHelpers.getHeaderName(source.headersObj, 'content-type')];
|
|
73
|
+
// Guzzle adds its own boundary for multipart requests.
|
|
74
|
+
if (headerHelpers.hasHeader(source.headersObj, 'content-type')) {
|
|
75
|
+
if (headerHelpers.getHeader(source.headersObj, 'content-type').includes('boundary')) {
|
|
76
|
+
// eslint-disable-next-line no-param-reassign
|
|
77
|
+
delete source.headersObj[headerHelpers.getHeaderName(source.headersObj, 'content-type')];
|
|
78
|
+
}
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
break;
|
|
@@ -31,7 +31,6 @@ const convert = function (obj, indent, lastIndent) {
|
|
|
31
31
|
result.push(convert(item, indent + indent, indent));
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
// eslint-disable-next-line sonarjs/no-nested-template-literals
|
|
35
34
|
result = `[\n${indent}${result.join(`,\n${indent}`)}\n${lastIndent}]`;
|
|
36
35
|
break;
|
|
37
36
|
|
|
@@ -44,7 +43,6 @@ const convert = function (obj, indent, lastIndent) {
|
|
|
44
43
|
result.push(`${convert(i, indent)} => ${convert(obj[i], indent + indent, indent)}`);
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
|
-
// eslint-disable-next-line sonarjs/no-nested-template-literals
|
|
48
46
|
result = `[\n${indent}${result.join(`,\n${indent}`)}\n${lastIndent}]`;
|
|
49
47
|
break;
|
|
50
48
|
|
package/src/targets/php/http2.js
CHANGED
|
@@ -40,41 +40,43 @@ module.exports = function (source, options) {
|
|
|
40
40
|
break;
|
|
41
41
|
|
|
42
42
|
case 'multipart/form-data': {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
if (source.postData.params) {
|
|
44
|
+
const files = [];
|
|
45
|
+
const fields = {};
|
|
46
|
+
|
|
47
|
+
source.postData.params.forEach(function (param) {
|
|
48
|
+
if (param.fileName) {
|
|
49
|
+
files.push({
|
|
50
|
+
name: param.name,
|
|
51
|
+
type: param.contentType,
|
|
52
|
+
file: param.fileName,
|
|
53
|
+
data: param.value,
|
|
54
|
+
});
|
|
55
|
+
} else if (param.value) {
|
|
56
|
+
fields[param.name] = param.value;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
60
|
+
code
|
|
61
|
+
.push('$body = new http\\Message\\Body;')
|
|
62
|
+
.push(
|
|
63
|
+
'$body->addForm(%s, %s);',
|
|
64
|
+
Object.keys(fields).length ? helpers.convert(fields, opts.indent) : 'null',
|
|
65
|
+
files.length ? helpers.convert(files, opts.indent) : 'null'
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
// remove the contentType header
|
|
69
|
+
if (headerHelpers.hasHeader(source.headersObj, 'content-type')) {
|
|
70
|
+
if (headerHelpers.getHeader(source.headersObj, 'content-type').includes('boundary')) {
|
|
71
|
+
// eslint-disable-next-line no-param-reassign
|
|
72
|
+
delete source.headersObj[headerHelpers.getHeaderName(source.headersObj, 'content-type')];
|
|
73
|
+
}
|
|
72
74
|
}
|
|
73
|
-
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
code.blank();
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
hasBody = true;
|
|
79
|
+
}
|
|
78
80
|
break;
|
|
79
81
|
}
|
|
80
82
|
|
|
@@ -75,16 +75,18 @@ module.exports = function (source, options) {
|
|
|
75
75
|
// construct post params
|
|
76
76
|
switch (source.postData.mimeType) {
|
|
77
77
|
case 'multipart/form-data':
|
|
78
|
-
source.postData.params
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
if (source.postData.params) {
|
|
79
|
+
source.postData.params.forEach(function (param) {
|
|
80
|
+
let post = '';
|
|
81
|
+
if (param.fileName) {
|
|
82
|
+
post = format('%s=@%s', param.name, param.fileName);
|
|
83
|
+
} else {
|
|
84
|
+
post = format('%s=%s', param.name, param.value);
|
|
85
|
+
}
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
code.push('%s %s', opts.short ? '-F' : '--form', helpers.quote(post));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
88
90
|
break;
|
|
89
91
|
|
|
90
92
|
case 'application/x-www-form-urlencoded':
|