From d46b67a5cf450c743a1c7087aadb5771539a302b Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 30 Nov 2019 11:56:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HttpFileManager.cpp | 4 ++-- src/Http/HttpSession.cpp | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Http/HttpFileManager.cpp b/src/Http/HttpFileManager.cpp index 800c0a6e..e4aebcf6 100644 --- a/src/Http/HttpFileManager.cpp +++ b/src/Http/HttpFileManager.cpp @@ -350,7 +350,7 @@ static void accessFile(TcpSession &sender, const Parser &parser, const MediaInfo if (cookie) { headerOut["Set-Cookie"] = cookie->getCookie((*cookie)[kCookiePathKey].get()); } - cb("401 Unauthorized", "", headerOut, std::make_shared(errMsg)); + cb("401 Unauthorized", "text/html", headerOut, std::make_shared(errMsg)); return; } @@ -380,7 +380,7 @@ void HttpFileManager::onAccessPath(TcpSession &sender, Parser &parser, const Htt auto strFile = File::absolutePath(enableVhost ? mediaInfo._vhost + parser.Url() : parser.Url(), rootPath); //访问的是文件夹 - if (strFile.back() == '/' || File::is_dir(strFile.data())) { + if (File::is_dir(strFile.data())) { auto indexFile = searchIndexFile(strFile); if (!indexFile.empty()) { //发现该文件夹下有index文件 diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index 3f01f567..bb2b3b5a 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -299,9 +299,7 @@ void HttpSession::Handle_Req_GET(int64_t &content_len) { if (!strongSelf) { return; } - strongSelf->sendResponse(status_code.data(), bClose, - content_type.empty() ? nullptr : content_type.data(), - responseHeader, body); + strongSelf->sendResponse(status_code.data(), bClose, content_type.data(), responseHeader, body); }); }); }