diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-07-01 11:38:25 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-07-01 11:38:25 +0000 |
| commit | 92c66d24acb2ef0c4324e682d32491bed04cab75 (patch) | |
| tree | 1123b7d1647b8500c63aa2739befb6ceb68e5ccb /src/DownloadCommand.cc | |
| parent | 61bb4bc02e662a33ae0d7a9747d28898ed847276 (diff) | |
2008-07-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten ChunkedEncoding class as ChunkedDecoder class.
* src/A2STR.cc
* src/A2STR.h
* src/ChunkedDecoder.cc
* src/ChunkedDecoder.h
* src/ChunkedEncoding.cc: Removed
* src/ChunkedEncoding.h: Removed
* src/DownloadCommand.cc
* src/DownloadCommand.h
* src/HttpDownloadCommand.cc
* src/HttpResponse.cc
* src/HttpResponse.h
* src/HttpResponseCommand.cc
* src/HttpSkipResponseCommand.cc
* src/HttpSkipResponseCommand.h
* src/Makefile.am
* src/TransferEncoding.h: Removed
* test/ChunkedDecoderTest.cc
* test/ChunkedEncodingTest.cc: Removed
* test/HttpResponseTest.cc
* test/Makefile.am
Diffstat (limited to 'src/DownloadCommand.cc')
| -rw-r--r-- | src/DownloadCommand.cc | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc index 2b4cfa7b..f7ba463f 100644 --- a/src/DownloadCommand.cc +++ b/src/DownloadCommand.cc @@ -123,19 +123,18 @@ bool DownloadCommand::executeInternal() { const SharedHandle<DiskAdaptor>& diskAdaptor = _requestGroup->getPieceStorage()->getDiskAdaptor(); - unsigned char* bufFinal; + const unsigned char* bufFinal; size_t bufSizeFinal; - if(transferDecoder.isNull()) { + std::string decoded; + if(_transferEncodingDecoder.isNull()) { bufFinal = buf; bufSizeFinal = bufSize; } else { - size_t infbufSize = 16*1024; - unsigned char infbuf[infbufSize]; - transferDecoder->inflate(infbuf, infbufSize, buf, bufSize); + decoded = _transferEncodingDecoder->decode(buf, bufSize); - bufFinal = infbuf; - bufSizeFinal = infbufSize; + bufFinal = reinterpret_cast<const unsigned char*>(decoded.c_str()); + bufSizeFinal = decoded.size(); } if(_contentEncodingDecoder.isNull()) { @@ -164,10 +163,10 @@ bool DownloadCommand::executeInternal() { if(_requestGroup->getTotalLength() != 0 && bufSize == 0) { throw DlRetryEx(EX_GOT_EOF); } - if((!transferDecoder.isNull() && transferDecoder->finished()) - || (transferDecoder.isNull() && segment->complete()) + if((!_transferEncodingDecoder.isNull() && + _transferEncodingDecoder->finished()) + || (_transferEncodingDecoder.isNull() && segment->complete()) || bufSize == 0) { - if(!transferDecoder.isNull()) transferDecoder->end(); logger->info(MSG_SEGMENT_DOWNLOAD_COMPLETED, cuid); if(!_contentEncodingDecoder.isNull() && @@ -284,9 +283,10 @@ void DownloadCommand::validatePieceHash(const SharedHandle<Segment>& segment, #endif // ENABLE_MESSAGE_DIGEST -void DownloadCommand::setTransferDecoder(const TransferEncodingHandle& transferDecoder) +void DownloadCommand::setTransferEncodingDecoder +(const SharedHandle<Decoder>& decoder) { - this->transferDecoder = transferDecoder; + this->_transferEncodingDecoder = decoder; } void DownloadCommand::setContentEncodingDecoder |
