2009-05-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Supported segmented downloading with chunked transfer encoding and
	content-length.	
	* src/DownloadCommand.cc
	* src/HttpResponseCommand.cc
pull/1/head
Tatsuhiro Tsujikawa 2009-05-05 15:19:02 +00:00
parent 7893340cb3
commit 3c877a9df4
3 changed files with 16 additions and 4 deletions

View File

@ -1,3 +1,10 @@
2009-05-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Supported segmented downloading with chunked transfer encoding and
content-length.
* src/DownloadCommand.cc
* src/HttpResponseCommand.cc
2009-05-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> 2009-05-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Bump up version number to 1.3.3 Bump up version number to 1.3.3

View File

@ -165,6 +165,7 @@ bool DownloadCommand::executeInternal() {
_requestGroup->getSegmentMan()->updateDownloadSpeedFor(peerStat); _requestGroup->getSegmentMan()->updateDownloadSpeedFor(peerStat);
bool segmentComplete = false; bool segmentComplete = false;
// Note that GrowSegment::complete() always returns false.
if(_transferEncodingDecoder.isNull() && _contentEncodingDecoder.isNull()) { if(_transferEncodingDecoder.isNull() && _contentEncodingDecoder.isNull()) {
if(segment->complete()) { if(segment->complete()) {
segmentComplete = true; segmentComplete = true;
@ -172,6 +173,8 @@ bool DownloadCommand::executeInternal() {
!socket->wantRead() && !socket->wantWrite()) { !socket->wantRead() && !socket->wantWrite()) {
segmentComplete = true; segmentComplete = true;
} }
} else if(!_transferEncodingDecoder.isNull() && segment->complete()) {
segmentComplete = true;
} else if((_transferEncodingDecoder.isNull() || } else if((_transferEncodingDecoder.isNull() ||
_transferEncodingDecoder->finished()) && _transferEncodingDecoder->finished()) &&
(_contentEncodingDecoder.isNull() || (_contentEncodingDecoder.isNull() ||

View File

@ -146,9 +146,10 @@ bool HttpResponseCommand::executeInternal()
// update last modified time // update last modified time
updateLastModifiedTime(httpResponse->getLastModifiedTime()); updateLastModifiedTime(httpResponse->getLastModifiedTime());
if(totalLength == 0 || httpResponse->isTransferEncodingSpecified() || // If both transfer-encoding and total length is specified, we
shouldInflateContentEncoding(httpResponse)) { // assume we can do segmented downloading
// we ignore content-length when transfer-encoding is set if(totalLength == 0 || shouldInflateContentEncoding(httpResponse)) {
// we ignore content-length when inflate is required
dctx->setTotalLength(0); dctx->setTotalLength(0);
if(req->getMethod() == Request::METHOD_GET && if(req->getMethod() == Request::METHOD_GET &&
(totalLength != 0 || (totalLength != 0 ||
@ -177,7 +178,8 @@ bool HttpResponseCommand::executeInternal()
getTransferEncodingDecoder(httpResponse), getTransferEncodingDecoder(httpResponse),
getContentEncodingDecoder(httpResponse))); getContentEncodingDecoder(httpResponse)));
} else { } else {
e->commands.push_back(createHttpDownloadCommand(httpResponse)); e->commands.push_back(createHttpDownloadCommand(httpResponse,
getTransferEncodingDecoder(httpResponse)));
} }
return true; return true;
} }