Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1518:eb46cc06389a | 1519:8bd0d897763f |
---|---|
32 #pragma once | 32 #pragma once |
33 | 33 |
34 #include "HttpFileSender.h" | 34 #include "HttpFileSender.h" |
35 #include "../FileStorage/FilesystemStorage.h" | 35 #include "../FileStorage/FilesystemStorage.h" |
36 | 36 |
37 #include <fstream> | |
38 | |
37 namespace Orthanc | 39 namespace Orthanc |
38 { | 40 { |
39 class FilesystemHttpSender : public HttpFileSender | 41 class FilesystemHttpSender : public HttpFileSender |
40 { | 42 { |
41 private: | 43 private: |
42 boost::filesystem::path path_; | 44 boost::filesystem::path path_; |
45 std::ifstream file_; | |
46 uint64_t size_; | |
47 std::string chunk_; | |
48 size_t chunkSize_; | |
43 | 49 |
44 void Setup(); | 50 void Open(); |
45 | |
46 protected: | |
47 virtual uint64_t GetFileSize(); | |
48 | |
49 virtual bool SendData(HttpOutput& output); | |
50 | 51 |
51 public: | 52 public: |
52 FilesystemHttpSender(const char* path); | 53 FilesystemHttpSender(const char* path); |
53 | 54 |
54 FilesystemHttpSender(const boost::filesystem::path& path); | 55 FilesystemHttpSender(const boost::filesystem::path& path); |
55 | 56 |
56 FilesystemHttpSender(const FilesystemStorage& storage, | 57 FilesystemHttpSender(const FilesystemStorage& storage, |
57 const std::string& uuid); | 58 const std::string& uuid); |
59 | |
60 | |
61 /** | |
62 * Implementation of the IHttpStreamAnswer interface. | |
63 **/ | |
64 | |
65 virtual uint64_t GetContentLength() | |
66 { | |
67 return size_; | |
68 } | |
69 | |
70 virtual bool ReadNextChunk(); | |
71 | |
72 virtual const char* GetChunkContent() | |
73 { | |
74 return chunk_.c_str(); | |
75 } | |
76 | |
77 virtual size_t GetChunkSize() | |
78 { | |
79 return chunkSize_; | |
80 } | |
58 }; | 81 }; |
59 } | 82 } |