修复html长度错误的bug

master 1.5.1
yutent 2023-04-28 15:44:40 +08:00
parent b3f73a0fae
commit 7fb2479033
2 changed files with 3 additions and 3 deletions

View File

@ -150,7 +150,7 @@ function createServer() {
.toString() .toString()
.replace('</head>', HMR_SCRIPT + '</head>') .replace('</head>', HMR_SCRIPT + '</head>')
res.setHeader('content-length', code.length) res.setHeader('content-length', Buffer.byteLength(code))
} else { } else {
res.setHeader('content-length', stat.size) res.setHeader('content-length', stat.size)
} }
@ -173,7 +173,7 @@ function createServer() {
res.setHeader('accept-ranges', 'bytes') res.setHeader('accept-ranges', 'bytes')
res.setHeader('content-type', MIME_TYPES.html) 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.writeHead(200, 'OK')
res.end(code) res.end(code)

View File

@ -2,7 +2,7 @@
"name": "simple-http", "name": "simple-http",
"displayName": "simple http", "displayName": "simple http",
"description": "🔥 简单的http服务器, 方便临时调试html", "description": "🔥 简单的http服务器, 方便临时调试html",
"version": "1.5.0", "version": "1.5.1",
"publisher": "yutent", "publisher": "yutent",
"author": "Yutent [@yutent]", "author": "Yutent [@yutent]",
"icon": "logo.png", "icon": "logo.png",