From ff34b937f350b862122cca876ccfa421ca5f842e Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Wed, 17 Jul 2019 14:54:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dhttp=E5=A4=B4=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HttpSession.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index ed015e50..24d83c70 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -913,16 +913,17 @@ void HttpSession::responseDelay(const string &Origin,bool bClose, sendNotFound(bClose); return; } - auto headerOther = makeHttpHeader(bClose,contentOut.size(),"text/plain"); + auto headerOther=makeHttpHeader(bClose,contentOut.size(),"text/plain"); if(!Origin.empty()){ headerOther["Access-Control-Allow-Origin"] = Origin; headerOther["Access-Control-Allow-Credentials"] = "true"; } - for (auto &pr : headerOut){ - //替换掉默认的http头 - headerOther[pr.first] = pr.second; + + for (auto &pr : headerOther){ + //添加默认http头,默认http头不能覆盖用户自定义的头 + const_cast(headerOut).emplace(pr.first,pr.second); } - sendResponse(codeOut.data(), headerOther, contentOut); + sendResponse(codeOut.data(), headerOut, contentOut); } inline void HttpSession::sendNotFound(bool bClose) { GET_CONFIG(string,notFound,Http::kNotFound);