From a779ec1d09ea63331ebaa27e0104f52622ba39d0 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Wed, 30 Mar 2022 23:59:34 -0500 Subject: [PATCH] Update content-length calculation to use buffer --- package.json | 2 +- src/http/lifecycle/Response.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2308cbf..a439566 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@extollo/lib", - "version": "0.9.20", + "version": "0.9.21", "description": "The framework library that lifts up your code.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/http/lifecycle/Response.ts b/src/http/lifecycle/Response.ts index 713cc3b..6c1fc12 100644 --- a/src/http/lifecycle/Response.ts +++ b/src/http/lifecycle/Response.ts @@ -243,7 +243,7 @@ export class Response { await this.sending$.next(this) if ( !(this.body instanceof Readable) ) { - this.setHeader('Content-Length', String((this.body?.length ?? 0) + 2)) + this.setHeader('Content-Length', String(Buffer.from(this.body ?? '').length)) } this.setHeader('Date', (new Date()).toUTCString())