diff --git a/lib/core/request.js b/lib/core/request.js index 2a13b0549a8..bbbac106833 100644 --- a/lib/core/request.js +++ b/lib/core/request.js @@ -80,13 +80,12 @@ class Request { this.body = null } else if (util.isStream(body)) { this.body = body - } else if (body instanceof DataView) { - // TODO: Why is DataView special? - this.body = body.buffer.byteLength ? Buffer.from(body.buffer) : null - } else if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) { - this.body = body.byteLength ? Buffer.from(body) : null } else if (util.isBuffer(body)) { this.body = body.byteLength ? body : null + } else if (ArrayBuffer.isView(body)) { + this.body = body.buffer.byteLength ? Buffer.from(body.buffer, body.byteOffset, body.byteLength) : null + } else if (body instanceof ArrayBuffer) { + this.body = body.byteLength ? Buffer.from(body) : null } else if (typeof body === 'string') { this.body = body.length ? Buffer.from(body) : null } else if (util.isFormDataLike(body) || util.isIterable(body) || util.isBlobLike(body)) {