Mercurial > hg > orthanc
diff Core/HttpServer/FilesystemHttpSender.cpp @ 1523:c388502a066d
testing FilesystemHttpSender
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Aug 2015 16:09:00 +0200 |
parents | f938f7779bcb |
children | f9b0169eb6bb |
line wrap: on
line diff
--- a/Core/HttpServer/FilesystemHttpSender.cpp Tue Aug 11 15:37:42 2015 +0200 +++ b/Core/HttpServer/FilesystemHttpSender.cpp Tue Aug 11 16:09:00 2015 +0200 @@ -62,8 +62,8 @@ } - HttpCompression FilesystemHttpSender::GetHttpCompression(bool gzipAllowed, - bool deflateAllowed) + HttpCompression FilesystemHttpSender::SetupHttpCompression(bool gzipAllowed, + bool deflateAllowed) { switch (sourceCompression_) { @@ -86,7 +86,8 @@ if (deflateAllowed) { - file_.seekg(sizeof(uint64_t), file_.end); + file_.seekg(sizeof(uint64_t), file_.beg); + size_ -= sizeof(uint64_t); return HttpCompression_Deflate; } else @@ -100,13 +101,16 @@ file_.read(&compressed[0], size_); if ((file_.flags() & std::istream::failbit) || - !(file_.flags() & std::istream::eofbit)) + !(file_.flags() & std::istream::eofbit) || + file_.gcount() < 0 || + static_cast<uint64_t>(file_.gcount()) != size_) { throw OrthancException(ErrorCode_CorruptedFile); } ZlibCompressor compressor; IBufferCompressor::Uncompress(uncompressed_->GetBuffer(), compressor, compressed); + return HttpCompression_None; } @@ -119,6 +123,19 @@ } + uint64_t FilesystemHttpSender::GetContentLength() + { + if (uncompressed_.get() != NULL) + { + return uncompressed_->GetContentLength(); + } + else + { + return size_; + } + } + + bool FilesystemHttpSender::ReadNextChunk() { if (uncompressed_.get() != NULL)