From 7401b3bd2c1537ae7cbab8b17622c4e486ec624d Mon Sep 17 00:00:00 2001 From: Jonatan Nilsson Date: Thu, 11 May 2023 09:50:52 +0000 Subject: [PATCH] requestEnd: Add proper support for buffers in body --- flaska.mjs | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/flaska.mjs b/flaska.mjs index 88002ac..679df06 100644 --- a/flaska.mjs +++ b/flaska.mjs @@ -989,7 +989,10 @@ ctx.state.nonce = nonce; let length = 0 - if (typeof(body) === 'object' && body) { + if (body instanceof Buffer) { + length = body.byteLength + ctx.type = ctx.type || 'application/octet-stream' + } else if (typeof(body) === 'object' && body) { body = JSON.stringify(body) length = Buffer.byteLength(body) ctx.type = 'application/json; charset=utf-8' diff --git a/package.json b/package.json index 54c6c1b..05bd337 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "flaska", - "version": "1.3.2", + "version": "1.3.3", "description": "Flaska is a micro web-framework for node. It is designed to be fast, simple and lightweight, and is distributed as a single file module with no dependencies.", "main": "flaska.mjs", "scripts": {