Commit ccddb84a by xia-chu

修复跨域问题: #2548

parent 72ba87c8
...@@ -594,6 +594,13 @@ void HttpSession::sendResponse(int code, ...@@ -594,6 +594,13 @@ void HttpSession::sendResponse(int code,
headerOut.emplace("Date", dateStr()); headerOut.emplace("Date", dateStr());
headerOut.emplace("Server", kServerName); headerOut.emplace("Server", kServerName);
headerOut.emplace("Connection", bClose ? "close" : "keep-alive"); headerOut.emplace("Connection", bClose ? "close" : "keep-alive");
GET_CONFIG(bool, allow_cross_domains, Http::kAllowCrossDomains);
if (allow_cross_domains) {
headerOut.emplace("Access-Control-Allow-Origin", "*");
headerOut.emplace("Access-Control-Allow-Credentials", "true");
}
if (!bClose) { if (!bClose) {
string keepAliveString = "timeout="; string keepAliveString = "timeout=";
keepAliveString += to_string(keepAliveSec); keepAliveString += to_string(keepAliveSec);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论