summaryrefslogtreecommitdiff
path: root/src/HttpDownloadCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-09-06 14:29:36 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-09-06 14:29:36 +0000
commitefbfe4c006cfb6e0bf3ee4ed57d0657c0cd85c19 (patch)
treea72723a125c34220772259f051673ff88598bded /src/HttpDownloadCommand.cc
parent552c753dbba55005964ad60698d803a44dac6391 (diff)
2010-09-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
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
Diffstat (limited to 'src/HttpDownloadCommand.cc')
-rw-r--r--src/HttpDownloadCommand.cc24
1 files changed, 15 insertions, 9 deletions
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