Skip to content

Commit 3fd4eee

Browse files
committed
Buffer-type chunks: support concatenation
1 parent dc87e4a commit 3fd4eee

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,14 @@ NodeHttpXHR.prototype.send = function (data) {
513513
if (typeof chunk === 'string') {
514514
this._responseText += chunk;
515515
} else if (typeof chunk === 'object') {
516-
// binary data usually comes in one chunk (no chunky transfer-encoding)
517-
// or at least, that's what we'll support here for now
518516
if (chunk instanceof Buffer) {
519-
this._response = chunk.buffer;
517+
if (this._response) {
518+
this._response = Buffer.concat([this._response, chunk]);
519+
} else {
520+
this._response = chunk;
521+
}
522+
// binary data usually comes in one chunk (no chunky transfer-encoding)
523+
// or at least, that's what we'll support here for now for ArrayBuffer
520524
} else if (chunk instanceof ArrayBuffer) {
521525
this._response = chunk;
522526
} else {

0 commit comments

Comments
 (0)