diff Core/HttpServer/HttpOutput.cpp @ 339:639272ef7615

answer raw buffers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 16 Jan 2013 15:14:54 +0100
parents 78a8eaa5f30b
children bdd72233b105
line wrap: on
line diff
--- a/Core/HttpServer/HttpOutput.cpp	Mon Jan 14 11:35:01 2013 +0100
+++ b/Core/HttpServer/HttpOutput.cpp	Wed Jan 16 15:14:54 2013 +0100
@@ -141,19 +141,24 @@
   }
 
 
+  void HttpOutput::PrepareCookies(Header& header,
+                                  const HttpHandler::Arguments& cookies)
+  {
+    for (HttpHandler::Arguments::const_iterator it = cookies.begin();
+         it != cookies.end(); it++)
+    {
+      header.push_back(std::make_pair("Set-Cookie", it->first + "=" + it->second));
+    }
+  }
+
+
   void HttpOutput::AnswerBufferWithContentType(const std::string& buffer,
                                                const std::string& contentType,
                                                const HttpHandler::Arguments& cookies)
   {
     Header header;
     PrepareOkHeader(header, contentType.c_str(), true, buffer.size(), NULL);
-    
-    for (HttpHandler::Arguments::const_iterator it = cookies.begin();
-         it != cookies.end(); it++)
-    {
-      header.push_back(std::make_pair("Set-Cookie", it->first + "=" + it->second));
-    }
-
+    PrepareCookies(header, cookies);
     SendOkHeader(header);
     SendString(buffer);
   }
@@ -167,6 +172,21 @@
     Send(buffer, size);
   }
 
+
+  void HttpOutput::AnswerBufferWithContentType(const void* buffer,
+                                               size_t size,
+                                               const std::string& contentType,
+                                               const HttpHandler::Arguments& cookies)
+  {
+    Header header;
+    PrepareOkHeader(header, contentType.c_str(), true, size, NULL);
+    PrepareCookies(header, cookies);
+    SendOkHeader(header);
+    Send(buffer, size);
+  }
+
+
+
   void HttpOutput::Redirect(const std::string& path)
   {
     std::string s =