changeset 1548:e9325f3ac496

Bypass zlib uncompression if "StorageCompression" is enabled and HTTP client supports deflate
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 14 Aug 2015 11:52:03 +0200
parents 5e65349c896b
children e5e975e9b738
files Core/Enumerations.cpp Core/Enumerations.h Core/HttpServer/HttpStreamTranscoder.cpp NEWS OrthancServer/ServerContext.cpp
diffstat 5 files changed, 28 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Enumerations.cpp	Fri Aug 14 11:26:44 2015 +0200
+++ b/Core/Enumerations.cpp	Fri Aug 14 11:52:03 2015 +0200
@@ -674,4 +674,21 @@
         return "application/octet-stream";
     }
   }
+
+
+  const char* GetFileExtension(FileContentType type)
+  {
+    switch (type)
+    {
+      case FileContentType_Dicom:
+        return ".dcm";
+
+      case FileContentType_DicomAsJson:
+        return ".json";
+
+      default:
+        // Unknown file type
+        return "";
+    }
+  }
 }
--- a/Core/Enumerations.h	Fri Aug 14 11:26:44 2015 +0200
+++ b/Core/Enumerations.h	Fri Aug 14 11:52:03 2015 +0200
@@ -378,4 +378,6 @@
                         const char* specificCharacterSet);
 
   const char* GetMimeType(FileContentType type);
+
+  const char* GetFileExtension(FileContentType type);
 }
--- a/Core/HttpServer/HttpStreamTranscoder.cpp	Fri Aug 14 11:26:44 2015 +0200
+++ b/Core/HttpServer/HttpStreamTranscoder.cpp	Fri Aug 14 11:52:03 2015 +0200
@@ -39,6 +39,8 @@
 #include <string.h>   // For memcpy()
 #include <cassert>
 
+#include <stdio.h>
+
 namespace Orthanc
 {
   void HttpStreamTranscoder::ReadSource(std::string& buffer)
--- a/NEWS	Fri Aug 14 11:26:44 2015 +0200
+++ b/NEWS	Fri Aug 14 11:52:03 2015 +0200
@@ -8,9 +8,10 @@
 Maintenance
 -----------
 
+* Many code refactorings
 * Upgrade to curl 7.44.0 for static and Windows builds
 * Upgrade to libcurl 1.0.2d for static and Windows builds
-* Many code refactorings
+* Bypass zlib uncompression if "StorageCompression" is enabled and HTTP client supports deflate
 
 
 Version 0.9.3 (2015/08/07)
--- a/OrthancServer/ServerContext.cpp	Fri Aug 14 11:26:44 2015 +0200
+++ b/OrthancServer/ServerContext.cpp	Fri Aug 14 11:52:03 2015 +0200
@@ -314,23 +314,15 @@
       throw OrthancException(ErrorCode_InternalError);
     }
 
-#if 1
-    accessor_.SetCompressionForNextOperations(attachment.GetCompressionType());
+    IStorageArea& area = accessor_.GetStorageArea();
 
-    std::auto_ptr<HttpFileSender> sender(accessor_.ConstructHttpFileSender(attachment.GetUuid(), attachment.GetContentType()));
-    sender->SetContentType(GetMimeType(content));
-    sender->SetContentFilename(attachment.GetUuid() + ".dcm");  // TODO ".dcm" => ToMimeType(content)
-    output.AnswerStream(*sender);
-#else
-    const FilesystemStorage& a = dynamic_cast<FilesystemStorage&>(accessor_.GetStorageArea());
-    
-    FilesystemHttpSender sender(a, attachment.GetUuid());
+    BufferHttpSender sender;
+    area.Read(sender.GetBuffer(), attachment.GetUuid(), content);
     sender.SetContentType(GetMimeType(content));
-    sender.SetContentFilename(attachment.GetUuid() + ".dcm");
-
+    sender.SetContentFilename(attachment.GetUuid() + std::string(GetFileExtension(content)));
+  
     HttpStreamTranscoder transcoder(sender, attachment.GetCompressionType());
     output.AnswerStream(transcoder);
-#endif
   }