From 7fb247903339a43642ccf27c5fbd509b327f303f Mon Sep 17 00:00:00 2001 From: yutent Date: Fri, 28 Apr 2023 15:44:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dhtml=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 5cfa439..dad53fd 100644 --- a/index.js +++ b/index.js @@ -150,7 +150,7 @@ function createServer() { .toString() .replace('', HMR_SCRIPT + '') - res.setHeader('content-length', code.length) + res.setHeader('content-length', Buffer.byteLength(code)) } else { res.setHeader('content-length', stat.size) } @@ -173,7 +173,7 @@ function createServer() { res.setHeader('accept-ranges', 'bytes') res.setHeader('content-type', MIME_TYPES.html) - res.setHeader('content-length', code.length) + res.setHeader('content-length', Buffer.byteLength(code)) res.writeHead(200, 'OK') res.end(code) diff --git a/package.json b/package.json index 4b65422..5b9046b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "simple-http", "displayName": "simple http", "description": "🔥 简单的http服务器, 方便临时调试html", - "version": "1.5.0", + "version": "1.5.1", "publisher": "yutent", "author": "Yutent [@yutent]", "icon": "logo.png",