[Poly > Request] Add encoding null support
This commit is contained in:
parent
82eaca1f72
commit
d335ad57fc
1 changed files with 4 additions and 4 deletions
|
@ -58,16 +58,16 @@ const request = (...args) => {
|
||||||
|
|
||||||
listeners['response']?.(res);
|
listeners['response']?.(res);
|
||||||
|
|
||||||
let body = '';
|
let data = [];
|
||||||
|
|
||||||
res.on('data', (chunk) => {
|
res.on('data', (chunk) => {
|
||||||
body += chunk;
|
data.push(chunk);
|
||||||
listeners['data']?.(chunk);
|
listeners['data']?.(chunk);
|
||||||
});
|
});
|
||||||
|
|
||||||
await new Promise((resolve) => res.on('end', resolve)); // Wait to read full body
|
await new Promise((resolve) => res.on('end', resolve)); // Wait to read full body
|
||||||
|
|
||||||
callback?.(undefined, res, body);
|
const buf = Buffer.concat(data);
|
||||||
|
callback?.(undefined, res, options.encoding !== null ? buf.toString() : buf);
|
||||||
});
|
});
|
||||||
|
|
||||||
const ret = {
|
const ret = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue