2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-21 13:24:11 +03:00

Avoid unnecessary Buffer allocations (#3321)

This commit is contained in:
Andrey Pechkurov
2021-12-22 21:50:05 +03:00
committed by GitHub
parent 716d5def2f
commit ebedf6b653
+1 -1
View File
@@ -293,7 +293,7 @@ module.exports = function httpAdapter(config) {
});
stream.on('end', function handleStreamEnd() {
var responseData = Buffer.concat(responseBuffer);
var responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
if (config.responseType !== 'arraybuffer') {
responseData = responseData.toString(config.responseEncoding);
if (!config.responseEncoding || config.responseEncoding === 'utf8') {