From: Scott Cantor Date: Fri, 27 Apr 2012 02:31:24 +0000 (+0000) Subject: Expose cookie map X-Git-Tag: 1.5.0~20 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-xmltooling.git;a=commitdiff_plain;h=0f4adab8ab6bdc458a4f35fb792f6fef47a9051f Expose cookie map --- diff --git a/xmltooling/io/HTTPRequest.cpp b/xmltooling/io/HTTPRequest.cpp index ef9c14a..f11e76f 100644 --- a/xmltooling/io/HTTPRequest.cpp +++ b/xmltooling/io/HTTPRequest.cpp @@ -228,7 +228,7 @@ namespace { } } -const char* HTTPRequest::getCookie(const char* name) const +const map& HTTPRequest::getCookies() const { if (m_cookieMap.empty()) { string cookies=getHeader("Cookie"); @@ -236,6 +236,11 @@ const char* HTTPRequest::getCookie(const char* name) const tokenizer< char_separator > nvpairs(cookies, char_separator(";")); for_each(nvpairs.begin(), nvpairs.end(), boost::bind(handle_cookie_fn, boost::ref(m_cookieMap), boost::ref(nvpair), _1)); } - map::const_iterator lookup=m_cookieMap.find(name); + return m_cookieMap; +} + +const char* HTTPRequest::getCookie(const char* name) const +{ + map::const_iterator lookup = getCookies().find(name); return (lookup==m_cookieMap.end()) ? nullptr : lookup->second.c_str(); } diff --git a/xmltooling/io/HTTPRequest.h b/xmltooling/io/HTTPRequest.h index d7e95c4..6568475 100644 --- a/xmltooling/io/HTTPRequest.h +++ b/xmltooling/io/HTTPRequest.h @@ -101,6 +101,13 @@ namespace xmltooling { */ virtual const char* getCookie(const char* name) const; + /** + * Gets all the cookies supplied by the client. + * + * @return a map of cookie name/value pairs + */ + virtual const std::map& getCookies() const; + private: mutable std::map m_cookieMap; };