mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2025-02-17 13:29:56 +08:00
修复http头重复的bug
This commit is contained in:
parent
c0a6981662
commit
917763c435
@ -16,7 +16,9 @@ namespace mediakit{
|
||||
string FindField(const char *buf, const char *start, const char *end, int bufSize = 0);
|
||||
|
||||
struct StrCaseCompare {
|
||||
bool operator()(const string &__x, const string &__y) const { return strcasecmp(__x.data(), __y.data()) < 0; }
|
||||
bool operator()(const string &__x, const string &__y) const {
|
||||
return strcasecmp(__x.data(), __y.data()) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -25,17 +27,19 @@ class StrCaseMap : public multimap<string, string, StrCaseCompare>{
|
||||
typedef multimap<string, string, StrCaseCompare> Super ;
|
||||
StrCaseMap() = default;
|
||||
~StrCaseMap() = default;
|
||||
string &operator[](const string &key){
|
||||
auto it = find(key);
|
||||
|
||||
template <class K>
|
||||
string &operator[](K &&k){
|
||||
auto it = find(std::forward<K>(k));
|
||||
if(it == end()){
|
||||
it = Super::emplace(key,"");
|
||||
it = Super::emplace(std::forward<K>(k),"");
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
template <class K,class V>
|
||||
void emplace(K &&k , V &&v) {
|
||||
auto it = find(k);
|
||||
auto it = find(std::forward<K>(k));
|
||||
if(it != end()){
|
||||
return;
|
||||
}
|
||||
|
@ -913,13 +913,16 @@ 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";
|
||||
}
|
||||
const_cast<KeyValue &>(headerOut).insert(headerOther.begin(), headerOther.end());
|
||||
sendResponse(codeOut.data(), headerOut, contentOut);
|
||||
for (auto &pr : headerOut){
|
||||
//替换掉默认的http头
|
||||
headerOther[pr.first] = pr.second;
|
||||
}
|
||||
sendResponse(codeOut.data(), headerOther, contentOut);
|
||||
}
|
||||
inline void HttpSession::sendNotFound(bool bClose) {
|
||||
GET_CONFIG(string,notFound,Http::kNotFound);
|
||||
|
Loading…
Reference in New Issue
Block a user