From 289ae659e045df6b9242e9589d80dff4fe1ebf7e Mon Sep 17 00:00:00 2001 From: Hans Date: Wed, 18 May 2022 14:36:06 +0800 Subject: [PATCH] Don't convert ArrayBuffer --- packages/server/js/response.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/server/js/response.js b/packages/server/js/response.js index d33c660..9103434 100644 --- a/packages/server/js/response.js +++ b/packages/server/js/response.js @@ -5,7 +5,11 @@ const mime = require('mime-types') const { Writable } = require('stream') function toArrayBuffer (buffer) { - return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength) + if (typeof buffer === 'object' && buffer.constructor.name === 'Buffer') { + return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength) + } else { + return buffer + } } const httpStatusCode = {