diff Core/RestApi/RestApiOutput.cpp @ 2981:eff50153a7b3 db-changes

integration mainline->db-changes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Dec 2018 15:58:08 +0100
parents d924f9bb61cc
children 4e43e67f8ecf
line wrap: on
line diff
--- a/Core/RestApi/RestApiOutput.cpp	Thu Oct 18 10:48:11 2018 +0200
+++ b/Core/RestApi/RestApiOutput.cpp	Thu Dec 06 15:58:08 2018 +0100
@@ -96,25 +96,28 @@
 #if ORTHANC_ENABLE_PUGIXML == 1
       std::string s;
       Toolbox::JsonToXml(s, value);
-      output_.SetContentType("application/xml; charset=utf-8");
+
+      output_.SetContentType(MIME_XML_UTF8);
       output_.Answer(s);
 #else
-      LOG(ERROR) << "Orthanc was compiled without XML support";
-      throw OrthancException(ErrorCode_InternalError);
+      throw OrthancException(ErrorCode_InternalError,
+                             "Orthanc was compiled without XML support");
 #endif
     }
     else
     {
       Json::StyledWriter writer;
-      output_.SetContentType("application/json; charset=utf-8");
-      output_.Answer(writer.write(value));
+      std::string s = writer.write(value);
+      
+      output_.SetContentType(MIME_JSON_UTF8);      
+      output_.Answer(s);
     }
 
     alreadySent_ = true;
   }
 
   void RestApiOutput::AnswerBuffer(const std::string& buffer,
-                                   const std::string& contentType)
+                                   MimeType contentType)
   {
     AnswerBuffer(buffer.size() == 0 ? NULL : buffer.c_str(),
                  buffer.size(), contentType);
@@ -122,10 +125,10 @@
 
   void RestApiOutput::AnswerBuffer(const void* buffer,
                                    size_t length,
-                                   const std::string& contentType)
+                                   MimeType contentType)
   {
     CheckStatus();
-    output_.SetContentType(contentType.c_str());
+    output_.SetContentType(contentType);
     output_.Answer(buffer, length);
     alreadySent_ = true;
   }