修复设置cookie错误的bug

This commit is contained in:
ziyue 2022-02-11 15:14:34 +08:00
parent 36f24527a4
commit 642c9c075a

View File

@ -393,7 +393,7 @@ static void accessFile(TcpSession &sender, const Parser &parser, const MediaInfo
//文件鉴权失败 //文件鉴权失败
StrCaseMap headerOut; StrCaseMap headerOut;
if (cookie) { if (cookie) {
headerOut["Set-Cookie"] = cookie->getAttach<HttpCookieAttachment>()._path; headerOut["Set-Cookie"] = cookie->getCookie(cookie->getAttach<HttpCookieAttachment>()._path);
} }
cb(401, "text/html", headerOut, std::make_shared<HttpStringBody>(errMsg)); cb(401, "text/html", headerOut, std::make_shared<HttpStringBody>(errMsg));
return; return;
@ -402,7 +402,7 @@ static void accessFile(TcpSession &sender, const Parser &parser, const MediaInfo
auto response_file = [file_exist, is_hls](const HttpServerCookie::Ptr &cookie, const HttpFileManager::invoker &cb, const string &strFile, const Parser &parser) { auto response_file = [file_exist, is_hls](const HttpServerCookie::Ptr &cookie, const HttpFileManager::invoker &cb, const string &strFile, const Parser &parser) {
StrCaseMap httpHeader; StrCaseMap httpHeader;
if (cookie) { if (cookie) {
httpHeader["Set-Cookie"] = cookie->getAttach<HttpCookieAttachment>()._path; httpHeader["Set-Cookie"] = cookie->getCookie(cookie->getAttach<HttpCookieAttachment>()._path);
} }
HttpSession::HttpResponseInvoker invoker = [&](int code, const StrCaseMap &headerOut, const HttpBody::Ptr &body) { HttpSession::HttpResponseInvoker invoker = [&](int code, const StrCaseMap &headerOut, const HttpBody::Ptr &body) {
if (cookie && file_exist) { if (cookie && file_exist) {
@ -519,7 +519,7 @@ void HttpFileManager::onAccessPath(TcpSession &sender, Parser &parser, const Htt
} }
StrCaseMap headerOut; StrCaseMap headerOut;
if (cookie) { if (cookie) {
headerOut["Set-Cookie"] = cookie->getAttach<HttpCookieAttachment>()._path; headerOut["Set-Cookie"] = cookie->getCookie(cookie->getAttach<HttpCookieAttachment>()._path);
} }
cb(errMsg.empty() ? 200 : 401, "text/html", headerOut, std::make_shared<HttpStringBody>(strMenu)); cb(errMsg.empty() ? 200 : 401, "text/html", headerOut, std::make_shared<HttpStringBody>(strMenu));
}); });