Skip to content

Commit

Permalink
Avoid unnecessary Buffer allocations (#3321)
Browse files Browse the repository at this point in the history
  • Loading branch information
puzpuzpuz committed Dec 22, 2021
1 parent 716d5de commit ebedf6b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/adapters/http.js
Expand Up @@ -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') {
Expand Down

0 comments on commit ebedf6b

Please sign in to comment.