From b8f8a14937b76e3498a3a3acf381c0d6af641ab9 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 9 Oct 2010 14:38:47 +0000 Subject: [PATCH] 2010-10-09 Tatsuhiro Tsujikawa Don't append slash in CookieStorage::criteriaFind(). Append file part of URI to request-uri in HttpRequest::createRequest(). This change reverts the part of the previous change:"The request-path must be ends with '/' so that request-path '/foo/' path-matches cookie-path '/foo' and '/foo/' in the proposed algorithm." * src/CookieStorage.cc * src/HttpRequest.cc --- ChangeLog | 11 +++++++++++ src/CookieStorage.cc | 6 ++---- src/HttpRequest.cc | 12 +++++++----- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf5b21a8..6bef94a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2010-10-09 Tatsuhiro Tsujikawa + + Don't append slash in CookieStorage::criteriaFind(). Append file + part of URI to request-uri in HttpRequest::createRequest(). This + change reverts the part of the previous change:"The + request-path must be ends with '/' so that request-path '/foo/' + path-matches cookie-path '/foo' and '/foo/' in the proposed + algorithm." + * src/CookieStorage.cc + * src/HttpRequest.cc + 2010-10-09 Tatsuhiro Tsujikawa Rewritten Cookie class and Cookie parser based on diff --git a/src/CookieStorage.cc b/src/CookieStorage.cc index 5cdd9d7c..fd547230 100644 --- a/src/CookieStorage.cc +++ b/src/CookieStorage.cc @@ -246,12 +246,10 @@ std::vector CookieStorage::criteriaFind if(requestPath.empty()) { return res; } - std::string normRequestPath = - requestPath == A2STR::SLASH_C?requestPath:requestPath+A2STR::SLASH_C; if(util::isNumericHost(requestHost)) { searchCookieByDomainSuffix (requestHost, domains_.begin(), domains_.end(), std::back_inserter(res), - requestHost, normRequestPath, now, secure); + requestHost, requestPath, now, secure); } else { std::vector levels; util::split(requestHost, std::back_inserter(levels),A2STR::DOT_C); @@ -263,7 +261,7 @@ std::vector CookieStorage::criteriaFind domain.insert(domain.begin(), (*i).begin(), (*i).end()); searchCookieByDomainSuffix (domain, domains_.begin(), domains_.end(), - std::back_inserter(res), requestHost, normRequestPath, now, secure); + std::back_inserter(res), requestHost, requestPath, now, secure); } } std::vector divs; diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 3e50ba0f..557b2163 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -225,11 +225,13 @@ std::string HttpRequest::createRequest() if(!cookieStorage_.isNull()) { std::string cookiesValue; std::vector cookies = - cookieStorage_->criteriaFind(getHost(), - getDir(), - Time().getTime(), - getProtocol() == Request::PROTO_HTTPS ? - true : false); + cookieStorage_->criteriaFind + (getHost(), + getDir() == A2STR::SLASH_C? + getDir()+getFile():strconcat(getDir(), A2STR::SLASH_C, getFile()), + Time().getTime(), + getProtocol() == Request::PROTO_HTTPS ? + true : false); for(std::vector::const_iterator itr = cookies.begin(), eoi = cookies.end(); itr != eoi; ++itr) { strappend(cookiesValue, (*itr).toString(), ";");