changeset 332:c51c9ed603e6

fixes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 09 Jan 2013 13:57:58 +0100
parents 5a96dac27959
children c730f6e42848
files Core/HttpServer/HttpHandler.cpp Core/RestApi/RestApi.h UnitTests/RestApi.cpp
diffstat 3 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Core/HttpServer/HttpHandler.cpp	Wed Jan 09 11:48:51 2013 +0100
+++ b/Core/HttpServer/HttpHandler.cpp	Wed Jan 09 13:57:58 2013 +0100
@@ -98,7 +98,7 @@
   {
     result.clear();
 
-    HttpHandler::Arguments::const_iterator it = httpHeaders.find("cookies");
+    HttpHandler::Arguments::const_iterator it = httpHeaders.find("cookie");
     if (it != httpHeaders.end())
     {
       const std::string& cookies = it->second;
--- a/Core/RestApi/RestApi.h	Wed Jan 09 11:48:51 2013 +0100
+++ b/Core/RestApi/RestApi.h	Wed Jan 09 13:57:58 2013 +0100
@@ -92,6 +92,11 @@
         return HttpHandler::GetArgument(*httpHeaders_, name, defaultValue);
       }
 
+      const HttpHandler::Arguments& GetHttpHeaders() const
+      {
+        return *httpHeaders_;
+      }
+
       void ParseCookies(HttpHandler::Arguments& result) const
       {
         HttpHandler::ParseCookies(result, *httpHeaders_);
--- a/UnitTests/RestApi.cpp	Wed Jan 09 11:48:51 2013 +0100
+++ b/UnitTests/RestApi.cpp	Wed Jan 09 13:57:58 2013 +0100
@@ -15,7 +15,7 @@
   HttpHandler::Arguments headers;
   HttpHandler::Arguments cookies;
 
-  headers["cookies"] = "a=b;c=d;;;e=f;;g=h;";
+  headers["cookie"] = "a=b;c=d;;;e=f;;g=h;";
   HttpHandler::ParseCookies(cookies, headers);
   ASSERT_EQ(4u, cookies.size());
   ASSERT_EQ("b", cookies["a"]);
@@ -23,17 +23,17 @@
   ASSERT_EQ("f", cookies["e"]);
   ASSERT_EQ("h", cookies["g"]);
 
-  headers["cookies"] = "  name =  value  ; name2=value2";
+  headers["cookie"] = "  name =  value  ; name2=value2";
   HttpHandler::ParseCookies(cookies, headers);
   ASSERT_EQ(2u, cookies.size());
   ASSERT_EQ("value", cookies["name"]);
   ASSERT_EQ("value2", cookies["name2"]);
 
-  headers["cookies"] = "  ;;;    ";
+  headers["cookie"] = "  ;;;    ";
   HttpHandler::ParseCookies(cookies, headers);
   ASSERT_EQ(0u, cookies.size());
 
-  headers["cookies"] = "  ;   n=v  ;;    ";
+  headers["cookie"] = "  ;   n=v  ;;    ";
   HttpHandler::ParseCookies(cookies, headers);
   ASSERT_EQ(1u, cookies.size());
   ASSERT_EQ("v", cookies["n"]);