mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
Avoid unnecessary Buffer allocations (#3321)
This commit is contained in:
@@ -293,7 +293,7 @@ module.exports = function httpAdapter(config) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
stream.on('end', function handleStreamEnd() {
|
stream.on('end', function handleStreamEnd() {
|
||||||
var responseData = Buffer.concat(responseBuffer);
|
var responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
|
||||||
if (config.responseType !== 'arraybuffer') {
|
if (config.responseType !== 'arraybuffer') {
|
||||||
responseData = responseData.toString(config.responseEncoding);
|
responseData = responseData.toString(config.responseEncoding);
|
||||||
if (!config.responseEncoding || config.responseEncoding === 'utf8') {
|
if (!config.responseEncoding || config.responseEncoding === 'utf8') {
|
||||||
|
|||||||
Reference in New Issue
Block a user