From fd52470fc920477f86ae48dfa3f145eebda88d6d Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 2 Dec 2023 20:55:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dhttp=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=9C=AA=E8=AE=BE=E7=BD=AEcharset?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HttpFileManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Http/HttpFileManager.cpp b/src/Http/HttpFileManager.cpp index 5a3217cd..9c95cef6 100644 --- a/src/Http/HttpFileManager.cpp +++ b/src/Http/HttpFileManager.cpp @@ -713,12 +713,12 @@ void HttpResponseInvokerImp::responseFile(const StrCaseMap &requestHeader, } //file是文件路径 + GET_CONFIG(string, charSet, Http::kCharSet); StrCaseMap &httpHeader = const_cast(responseHeader); auto fileBody = std::make_shared(file, use_mmap); if (fileBody->remainSize() < 0) { //打开文件失败 GET_CONFIG(string, notFound, Http::kNotFound); - GET_CONFIG(string, charSet, Http::kCharSet); auto strContentType = StrPrinter << "text/html; charset=" << charSet << endl; httpHeader["Content-Type"] = strContentType; @@ -727,7 +727,7 @@ void HttpResponseInvokerImp::responseFile(const StrCaseMap &requestHeader, } // 尝试添加Content-Type - httpHeader.emplace("Content-Type", HttpConst::getHttpContentType(file.data())); + httpHeader.emplace("Content-Type", HttpConst::getHttpContentType(file.data()) + "; charset=" + charSet); auto &strRange = const_cast(requestHeader)["Range"]; int code = 200;