From efbfe4c006cfb6e0bf3ee4ed57d0657c0cd85c19 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 6 Sep 2010 14:29:36 +0000 Subject: 2010-09-06 Tatsuhiro Tsujikawa Data from remote server in HTTP/FTP download are now written to the disk(or memory) through StreamFilter. Decoding chunked and gziped streams are done cascading StreamFilter. Removed inefficient 1byte read code. * src/ChunkedDecodingStreamFilter.cc * src/ChunkedDecodingStreamFilter.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/GZipDecodingStreamFilter.cc * src/GZipDecodingStreamFilter.h * src/HttpConnection.cc * src/HttpDownloadCommand.cc * src/HttpResponse.cc * src/HttpResponse.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/Makefile.am * src/NullSinkStreamFilter.cc * src/NullSinkStreamFilter.h * src/RequestGroup.cc * src/SinkStreamFilter.cc * src/SinkStreamFilter.h * src/StreamFilter.cc * src/StreamFilter.h * test/ChunkedDecodingStreamFilterTest.cc * test/GZipDecodingStreamFilterTest.cc * test/HttpResponseTest.cc * test/Makefile.am * test/MockSegment.h --- src/HttpDownloadCommand.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/HttpDownloadCommand.cc') diff --git a/src/HttpDownloadCommand.cc b/src/HttpDownloadCommand.cc index 52ba1ed7..7a304682 100644 --- a/src/HttpDownloadCommand.cc +++ b/src/HttpDownloadCommand.cc @@ -47,12 +47,15 @@ #include "HttpHeader.h" #include "Range.h" #include "DownloadContext.h" -#include "Decoder.h" #include "RequestGroupMan.h" #include "FileAllocationEntry.h" #include "CheckIntegrityEntry.h" #include "ServerStatMan.h" #include "Logger.h" +#include "StreamFilter.h" +#include "SinkStreamFilter.h" +#include "util.h" + namespace aria2 { HttpDownloadCommand::HttpDownloadCommand @@ -88,18 +91,16 @@ bool HttpDownloadCommand::prepareForNextSegment() { if(getRequest()->isPipeliningEnabled() || (getRequest()->isKeepAliveEnabled() && ( - // Make sure that all decoders are finished to pool socket - ((!getTransferEncodingDecoder().isNull() && - getTransferEncodingDecoder()->finished()) || - (getTransferEncodingDecoder().isNull() && - !getContentEncodingDecoder().isNull() && - getContentEncodingDecoder()->finished())) || + // Make sure that all filters are finished to pool socket + (!util::endsWith(getStreamFilter()->getName(), + SinkStreamFilter::NAME) && + getStreamFilter()->finished()) || getRequestEndOffset() == getFileEntry()->gtoloff(getSegments().front()->getPositionToWrite()) ) ) ) { - // TODO What if server sends EOF when _contentEncodingDecoder is + // TODO What if server sends EOF when non-SinkStreamFilter is // used and server didn't send Connection: close? We end up to // pool terminated socket. In HTTP/1.1, keep-alive is default, // so closing connection without Connection: close header means @@ -133,7 +134,12 @@ bool HttpDownloadCommand::prepareForNextSegment() { off_t HttpDownloadCommand::getRequestEndOffset() const { - return httpResponse_->getHttpHeader()->getRange()->getEndByte()+1; + off_t endByte = httpResponse_->getHttpHeader()->getRange()->getEndByte(); + if(endByte > 0) { + return endByte+1; + } else { + return endByte; + } } } // namespace aria2 -- cgit