@jnode/request 1.1.1 → 1.1.3
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 +1 -1
- package/src/index.js +7 -5
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -30,7 +30,7 @@ function request(method, url, headers = {}, body) {
|
|
|
30
30
|
headers: headers
|
|
31
31
|
}, (res) => {
|
|
32
32
|
let chunks = [];
|
|
33
|
-
res.on('data', chunks.push);
|
|
33
|
+
res.on('data', (chunk) => chunks.push(chunk));
|
|
34
34
|
res.on('end', () => {
|
|
35
35
|
resolve(new RequestResponse(res, Buffer.concat(chunks)));
|
|
36
36
|
});
|
|
@@ -78,7 +78,7 @@ async function multipartRequest(method, url, headers, parts, options) {
|
|
|
78
78
|
const req = reqModule.request(url, options, (res) => {
|
|
79
79
|
//save buffers
|
|
80
80
|
let chunks = [];
|
|
81
|
-
res.on('data', chunks.push);
|
|
81
|
+
res.on('data', (chunk) => chunks.push(chunk));
|
|
82
82
|
|
|
83
83
|
res.on('end', () => {
|
|
84
84
|
resolve(new RequestResponse(res, Buffer.concat(chunks)));
|
|
@@ -114,10 +114,12 @@ async function multipartRequest(method, url, headers, parts, options) {
|
|
|
114
114
|
req.write('\r\n');
|
|
115
115
|
} else if (part.data) { //string or buffer data
|
|
116
116
|
req.write('\r\n');
|
|
117
|
-
req.write(part.data
|
|
117
|
+
req.write(part.data);
|
|
118
|
+
req.write('\r\n');
|
|
118
119
|
} else if (part.base64) { //base64 data
|
|
119
120
|
req.write('Content-Transfer-Encoding: base64\r\n\r\n'); //using base64 encoding
|
|
120
|
-
req.write(part.base64
|
|
121
|
+
req.write(part.base64);
|
|
122
|
+
req.write('\r\n');
|
|
121
123
|
} else if (part.stream) { //any readable stream
|
|
122
124
|
req.write('\r\n');
|
|
123
125
|
await pipeline(part.stream, req, { end: false });
|
|
@@ -126,7 +128,7 @@ async function multipartRequest(method, url, headers, parts, options) {
|
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
//end request
|
|
129
|
-
req.write(`--${boundary}
|
|
131
|
+
req.write(`--${boundary}--`);
|
|
130
132
|
req.end();
|
|
131
133
|
});
|
|
132
134
|
}
|