修复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);
|
string FindField(const char *buf, const char *start, const char *end, int bufSize = 0);
|
||||||
|
|
||||||
struct StrCaseCompare {
|
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 ;
|
typedef multimap<string, string, StrCaseCompare> Super ;
|
||||||
StrCaseMap() = default;
|
StrCaseMap() = default;
|
||||||
~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()){
|
if(it == end()){
|
||||||
it = Super::emplace(key,"");
|
it = Super::emplace(std::forward<K>(k),"");
|
||||||
}
|
}
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K,class V>
|
template <class K,class V>
|
||||||
void emplace(K &&k , V &&v) {
|
void emplace(K &&k , V &&v) {
|
||||||
auto it = find(k);
|
auto it = find(std::forward<K>(k));
|
||||||
if(it != end()){
|
if(it != end()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -913,13 +913,16 @@ 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";
|
||||||
}
|
}
|
||||||
const_cast<KeyValue &>(headerOut).insert(headerOther.begin(), headerOther.end());
|
for (auto &pr : headerOut){
|
||||||
sendResponse(codeOut.data(), headerOut, contentOut);
|
//替换掉默认的http头
|
||||||
|
headerOther[pr.first] = pr.second;
|
||||||
|
}
|
||||||
|
sendResponse(codeOut.data(), headerOther, 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);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue