comparison Core/HttpServer/BufferHttpSender.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
37 { 37 {
38 class BufferHttpSender : public HttpFileSender 38 class BufferHttpSender : public HttpFileSender
39 { 39 {
40 private: 40 private:
41 std::string buffer_; 41 std::string buffer_;
42 bool done_;
42 43
43 protected: 44 public:
44 virtual uint64_t GetFileSize() 45 BufferHttpSender() : done_(false)
45 { 46 {
46 return buffer_.size();
47 } 47 }
48 48
49 virtual bool SendData(HttpOutput& output)
50 {
51 if (buffer_.size())
52 {
53 output.SendBody(&buffer_[0], buffer_.size());
54 }
55
56 return true;
57 }
58
59 public:
60 std::string& GetBuffer() 49 std::string& GetBuffer()
61 { 50 {
62 return buffer_; 51 return buffer_;
63 } 52 }
64 53
65 const std::string& GetBuffer() const 54 const std::string& GetBuffer() const
66 { 55 {
67 return buffer_; 56 return buffer_;
68 } 57 }
58
59
60 /**
61 * Implementation of the IHttpStreamAnswer interface.
62 **/
63
64 virtual uint64_t GetContentLength()
65 {
66 return buffer_.size();
67 }
68
69 virtual bool ReadNextChunk();
70
71 virtual const char* GetChunkContent();
72
73 virtual size_t GetChunkSize();
69 }; 74 };
70 } 75 }