Mercurial > hg > orthanc
diff Core/HttpServer/BufferHttpSender.cpp @ 1525:f9b0169eb6bb
testing
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Aug 2015 17:50:38 +0200 |
parents | 4a503a8c7749 |
children | b1291df2f780 |
line wrap: on
line diff
--- a/Core/HttpServer/BufferHttpSender.cpp Tue Aug 11 16:09:24 2015 +0200 +++ b/Core/HttpServer/BufferHttpSender.cpp Tue Aug 11 17:50:38 2015 +0200 @@ -34,28 +34,51 @@ #include "../OrthancException.h" +#include <cassert> + namespace Orthanc { + BufferHttpSender::BufferHttpSender() : + position_(0), + chunkSize_(0), + currentChunkSize_(0) + { + } + + bool BufferHttpSender::ReadNextChunk() { - if (done_) + assert(position_ + currentChunkSize_ <= buffer_.size()); + + position_ += currentChunkSize_; + + if (position_ == buffer_.size()) { return false; } else { - done_ = true; + currentChunkSize_ = buffer_.size() - position_; + + if (chunkSize_ != 0 && + currentChunkSize_ > chunkSize_) + { + currentChunkSize_ = chunkSize_; + } + return true; } } + const char* BufferHttpSender::GetChunkContent() { - return buffer_.c_str(); + return buffer_.c_str() + position_; } + size_t BufferHttpSender::GetChunkSize() { - return buffer_.size(); + return currentChunkSize_; } }