diff Core/RestApi/RestApiOutput.cpp @ 1511:7962563129c9

starting support of deflate/gzip content types
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Aug 2015 14:18:24 +0200
parents f967bdf8534e
children d73a2178b319
line wrap: on
line diff
--- a/Core/RestApi/RestApiOutput.cpp	Mon Aug 10 10:27:05 2015 +0200
+++ b/Core/RestApi/RestApiOutput.cpp	Mon Aug 10 14:18:24 2015 +0200
@@ -45,6 +45,7 @@
                                HttpMethod method) : 
     output_(output),
     method_(method),
+    compression_(HttpCompression_None),
     convertJsonToXml_(false)
   {
     alreadySent_ = false;
@@ -94,7 +95,7 @@
       std::string s;
       Toolbox::JsonToXml(s, value);
       output_.SetContentType("application/xml");
-      output_.SendBody(s);
+      output_.SendBody(s, compression_);
 #else
       LOG(ERROR) << "Orthanc was compiled without XML support";
       throw OrthancException(ErrorCode_InternalError);
@@ -104,7 +105,7 @@
     {
       Json::StyledWriter writer;
       output_.SetContentType("application/json");
-      output_.SendBody(writer.write(value));
+      output_.SendBody(writer.write(value), compression_);
     }
 
     alreadySent_ = true;
@@ -115,7 +116,7 @@
   {
     CheckStatus();
     output_.SetContentType(contentType.c_str());
-    output_.SendBody(buffer);
+    output_.SendBody(buffer, compression_);
     alreadySent_ = true;
   }
 
@@ -125,7 +126,7 @@
   {
     CheckStatus();
     output_.SetContentType(contentType.c_str());
-    output_.SendBody(buffer, length);
+    output_.SendBody(buffer, length, compression_);
     alreadySent_ = true;
   }