comparison Core/HttpServer/FilesystemHttpSender.h @ 1522:f938f7779bcb

fixes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Aug 2015 15:37:42 +0200
parents 8bd0d897763f
children c388502a066d
comparison
equal deleted inserted replaced
1521:3606278d305e 1522:f938f7779bcb
30 **/ 30 **/
31 31
32 #pragma once 32 #pragma once
33 33
34 #include "HttpFileSender.h" 34 #include "HttpFileSender.h"
35 #include "BufferHttpSender.h"
35 #include "../FileStorage/FilesystemStorage.h" 36 #include "../FileStorage/FilesystemStorage.h"
36 37
37 #include <fstream> 38 #include <fstream>
38 39
39 namespace Orthanc 40 namespace Orthanc
40 { 41 {
41 class FilesystemHttpSender : public HttpFileSender 42 class FilesystemHttpSender : public HttpFileSender
42 { 43 {
43 private: 44 private:
44 boost::filesystem::path path_; 45 std::ifstream file_;
45 std::ifstream file_; 46 uint64_t size_;
46 uint64_t size_; 47 std::string chunk_;
47 std::string chunk_; 48 size_t chunkSize_;
48 size_t chunkSize_; 49 CompressionType sourceCompression_;
50 HttpCompression targetCompression_;
49 51
50 void Open(); 52 std::auto_ptr<BufferHttpSender> uncompressed_;
53
54 void Initialize(const boost::filesystem::path& path);
51 55
52 public: 56 public:
53 FilesystemHttpSender(const char* path); 57 FilesystemHttpSender(const std::string& path)
58 {
59 Initialize(path);
60 }
54 61
55 FilesystemHttpSender(const boost::filesystem::path& path); 62 FilesystemHttpSender(const boost::filesystem::path& path)
63 {
64 Initialize(path);
65 }
56 66
57 FilesystemHttpSender(const FilesystemStorage& storage, 67 FilesystemHttpSender(const FilesystemStorage& storage,
58 const std::string& uuid); 68 const std::string& uuid)
69 {
70 Initialize(storage.GetPath(uuid));
71 }
72
73 void SetSourceCompression(CompressionType compression)
74 {
75 sourceCompression_ = compression;
76 }
59 77
60 78
61 /** 79 /**
62 * Implementation of the IHttpStreamAnswer interface. 80 * Implementation of the IHttpStreamAnswer interface.
63 **/ 81 **/
82
83 virtual HttpCompression GetHttpCompression(bool /*gzipAllowed*/,
84 bool /*deflateAllowed*/);
64 85
65 virtual uint64_t GetContentLength() 86 virtual uint64_t GetContentLength()
66 { 87 {
67 return size_; 88 return size_;
68 } 89 }
69 90
70 virtual bool ReadNextChunk(); 91 virtual bool ReadNextChunk();
71 92
72 virtual const char* GetChunkContent() 93 virtual const char* GetChunkContent();
73 {
74 return chunk_.c_str();
75 }
76 94
77 virtual size_t GetChunkSize() 95 virtual size_t GetChunkSize();
78 {
79 return chunkSize_;
80 }
81 }; 96 };
82 } 97 }