Expose cookie map
authorscantor <scantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Fri, 27 Apr 2012 02:31:24 +0000 (02:31 +0000)
committerscantor <scantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Fri, 27 Apr 2012 02:31:24 +0000 (02:31 +0000)
git-svn-id: https://svn.shibboleth.net/cpp-xmltooling/branches/REL_1@971 de75baf8-a10c-0410-a50a-987c0e22f00f

xmltooling/io/HTTPRequest.cpp
xmltooling/io/HTTPRequest.h

index ef9c14a..f11e76f 100644 (file)
@@ -228,7 +228,7 @@ namespace {
     }
 }
 
-const char* HTTPRequest::getCookie(const char* name) const
+const map<string,string>& 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<char> > nvpairs(cookies, char_separator<char>(";"));
         for_each(nvpairs.begin(), nvpairs.end(), boost::bind(handle_cookie_fn, boost::ref(m_cookieMap), boost::ref(nvpair), _1));
     }
-    map<string,string>::const_iterator lookup=m_cookieMap.find(name);
+    return m_cookieMap;
+}
+
+const char* HTTPRequest::getCookie(const char* name) const
+{
+    map<string,string>::const_iterator lookup = getCookies().find(name);
     return (lookup==m_cookieMap.end()) ? nullptr : lookup->second.c_str();
 }
index d7e95c4..6568475 100644 (file)
@@ -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<std::string,std::string>& getCookies() const;
+
     private:
         mutable std::map<std::string,std::string> m_cookieMap;
     };