diff Core/HttpServer/FilesystemHttpSender.h @ 1519:8bd0d897763f

refactoring: IHttpStreamAnswer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Aug 2015 13:15:16 +0200
parents 6e7e5ed91c2d
children f938f7779bcb
line wrap: on
line diff
--- a/Core/HttpServer/FilesystemHttpSender.h	Tue Aug 11 10:36:05 2015 +0200
+++ b/Core/HttpServer/FilesystemHttpSender.h	Tue Aug 11 13:15:16 2015 +0200
@@ -34,19 +34,20 @@
 #include "HttpFileSender.h"
 #include "../FileStorage/FilesystemStorage.h"
 
+#include <fstream>
+
 namespace Orthanc
 {
   class FilesystemHttpSender : public HttpFileSender
   {
   private:
     boost::filesystem::path path_;
-
-    void Setup();
+    std::ifstream           file_;
+    uint64_t                size_;
+    std::string             chunk_;
+    size_t                  chunkSize_;
 
-  protected:
-    virtual uint64_t GetFileSize();
-
-    virtual bool SendData(HttpOutput& output);
+    void Open();
 
   public:
     FilesystemHttpSender(const char* path);
@@ -55,5 +56,27 @@
 
     FilesystemHttpSender(const FilesystemStorage& storage,
                          const std::string& uuid);
+
+
+    /**
+     * Implementation of the IHttpStreamAnswer interface.
+     **/
+
+    virtual uint64_t GetContentLength()
+    {
+      return size_;
+    }
+
+    virtual bool ReadNextChunk();
+
+    virtual const char* GetChunkContent()
+    {
+      return chunk_.c_str();
+    }
+
+    virtual size_t GetChunkSize()
+    {
+      return chunkSize_;
+    }
   };
 }