Core: HttpRequest improved cookie precendence

git-svn-id: svn://ultimatepp.org/upp/trunk@4996 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2012-05-22 13:35:05 +00:00
parent 6ecaedceb1
commit 8f22ce895c

View file

@ -485,15 +485,23 @@ void HttpRequest::StartRequest()
if(ctype.GetCount())
data << "Content-Type: " << ctype << "\r\n";
}
String cs;
VectorMap<String, Tuple2<String, int> > cms;
for(int i = 0; i < cookies.GetCount(); i++) {
const HttpCookie& c = cookies[i];
if(host.EndsWith(c.domain) && path.StartsWith(c.path)) {
if(cs.GetCount())
cs << "; ";
cs << c.id << '=' << c.value;
Tuple2<String, int>& m = cms.GetAdd(c.id, MakeTuple(String(), -1));
if(c.path.GetLength() > m.b) {
m.a = c.value;
m.b = c.path.GetLength();
}
}
}
String cs;
for(int i = 0; i < cms.GetCount(); i++) {
if(i)
cs << "; ";
cs << cms.GetKey(i) << '=' << cms[i].a;
}
if(cs.GetCount())
data << "Cookie: " << cs << "\r\n";
if(!IsNull(proxy_host) && !IsNull(proxy_username))