diff --git a/__tests__/integration.js b/__tests__/integration.js index 25528b34..2fb73195 100644 --- a/__tests__/integration.js +++ b/__tests__/integration.js @@ -9,7 +9,6 @@ const { makeResponse, EACH_MATRIX } = require('../jest-helpers') - const jestHelpersPath = path.join(__dirname, '..', 'jest-helpers') let app, router, serverlessExpressInstance diff --git a/src/response.js b/src/response.js index 4aa1d712..a65e0208 100644 --- a/src/response.js +++ b/src/response.js @@ -12,13 +12,15 @@ function getString (data) { return data.toString('utf8') } else if (typeof data === 'string') { return data + } else if (data instanceof Uint8Array) { + return new TextDecoder().decode(data) } else { throw new Error(`response.write() of unexpected type: ${typeof data}`) } } function addData (stream, data) { - if (Buffer.isBuffer(data) || typeof data === 'string') { + if (Buffer.isBuffer(data) || typeof data === 'string' || data instanceof Uint8Array) { stream[BODY].push(Buffer.from(data)) } else { throw new Error(`response.write() of unexpected type: ${typeof data}`)