Commit ff34b937 by xiongziliang

修复http头重复的bug

parent 917763c4
...@@ -913,16 +913,17 @@ void HttpSession::responseDelay(const string &Origin,bool bClose, ...@@ -913,16 +913,17 @@ void HttpSession::responseDelay(const string &Origin,bool bClose,
sendNotFound(bClose); sendNotFound(bClose);
return; return;
} }
auto headerOther = makeHttpHeader(bClose,contentOut.size(),"text/plain"); auto headerOther=makeHttpHeader(bClose,contentOut.size(),"text/plain");
if(!Origin.empty()){ if(!Origin.empty()){
headerOther["Access-Control-Allow-Origin"] = Origin; headerOther["Access-Control-Allow-Origin"] = Origin;
headerOther["Access-Control-Allow-Credentials"] = "true"; headerOther["Access-Control-Allow-Credentials"] = "true";
} }
for (auto &pr : headerOut){
//替换掉默认的http头 for (auto &pr : headerOther){
headerOther[pr.first] = pr.second; //添加默认http头,默认http头不能覆盖用户自定义的头
const_cast<KeyValue &>(headerOut).emplace(pr.first,pr.second);
} }
sendResponse(codeOut.data(), headerOther, contentOut); sendResponse(codeOut.data(), headerOut, contentOut);
} }
inline void HttpSession::sendNotFound(bool bClose) { inline void HttpSession::sendNotFound(bool bClose) {
GET_CONFIG(string,notFound,Http::kNotFound); GET_CONFIG(string,notFound,Http::kNotFound);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论