From 8f22ce895cf84fb7437b125f406fee00b6f347ff Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 22 May 2012 13:35:05 +0000 Subject: [PATCH] Core: HttpRequest improved cookie precendence git-svn-id: svn://ultimatepp.org/upp/trunk@4996 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Http.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/uppsrc/Core/Http.cpp b/uppsrc/Core/Http.cpp index 0cdabdd15..9c4e147ab 100644 --- a/uppsrc/Core/Http.cpp +++ b/uppsrc/Core/Http.cpp @@ -485,15 +485,23 @@ void HttpRequest::StartRequest() if(ctype.GetCount()) data << "Content-Type: " << ctype << "\r\n"; } - String cs; + VectorMap > 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& 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))