mirror of https://github.com/aria2/aria2
2010-09-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that error occurs when downloading zero-length file. * src/FtpNegotiationCommand.cc * src/HttpResponseCommand.ccpull/1/head
parent
5bf8a53b3f
commit
97953dd1ae
|
@ -1,3 +1,9 @@
|
|||
2010-09-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Fixed the bug that error occurs when downloading zero-length file.
|
||||
* src/FtpNegotiationCommand.cc
|
||||
* src/HttpResponseCommand.cc
|
||||
|
||||
2010-09-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Fixed compile error without OpenSSL/GnuTLS.
|
||||
|
|
|
@ -403,7 +403,8 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength)
|
|||
return false;
|
||||
}
|
||||
|
||||
if(getRequestGroup()->downloadFinishedByFileLength()) {
|
||||
if(getDownloadContext()->knowsTotalLength() &&
|
||||
getRequestGroup()->downloadFinishedByFileLength()) {
|
||||
getRequestGroup()->initPieceStorage();
|
||||
getPieceStorage()->markAllPiecesDone();
|
||||
// TODO It would be good to issue ChecksumCheckIntegrity here
|
||||
|
@ -425,6 +426,7 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength)
|
|||
|
||||
if(getDownloadContext()->knowsTotalLength()) {
|
||||
sequence_ = SEQ_DOWNLOAD_ALREADY_COMPLETED;
|
||||
getPieceStorage()->markAllPiecesDone();
|
||||
poolConnection();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -375,8 +375,21 @@ bool HttpResponseCommand::handleOtherEncoding
|
|||
return prepareForRetry(0);
|
||||
}
|
||||
|
||||
// In this context, knowsTotalLength() is true only when the file is
|
||||
// really zero-length.
|
||||
|
||||
SharedHandle<StreamFilter> streamFilter =
|
||||
getTransferEncodingStreamFilter
|
||||
(httpResponse,
|
||||
getContentEncodingStreamFilter(httpResponse));
|
||||
// If chunked transfer-encoding is specified, we have to read end of
|
||||
// chunk markers(0\r\n\r\n, for example).
|
||||
bool chunkedUsed = !streamFilter.isNull() &&
|
||||
streamFilter->getName() == ChunkedDecodingStreamFilter::NAME;
|
||||
|
||||
// For zero-length file, check existing file comparing its size
|
||||
if(getRequestGroup()->downloadFinishedByFileLength()) {
|
||||
if(!chunkedUsed && getDownloadContext()->knowsTotalLength() &&
|
||||
getRequestGroup()->downloadFinishedByFileLength()) {
|
||||
getRequestGroup()->initPieceStorage();
|
||||
getPieceStorage()->markAllPiecesDone();
|
||||
// This is zero-size file, so hash check is no use.
|
||||
|
@ -392,19 +405,11 @@ bool HttpResponseCommand::handleOtherEncoding
|
|||
getRequestGroup()->initPieceStorage();
|
||||
getPieceStorage()->getDiskAdaptor()->initAndOpenFile();
|
||||
|
||||
SharedHandle<StreamFilter> streamFilter =
|
||||
getTransferEncodingStreamFilter
|
||||
(httpResponse,
|
||||
getContentEncodingStreamFilter(httpResponse));
|
||||
|
||||
// In this context, knowsTotalLength() is true only when the file is
|
||||
// really zero-length.
|
||||
if(getDownloadContext()->knowsTotalLength() &&
|
||||
(streamFilter.isNull() ||
|
||||
streamFilter->getName() != ChunkedDecodingStreamFilter::NAME)) {
|
||||
// If chunked transfer-encoding is specified, we have to read end
|
||||
// of chunk markers(0\r\n\r\n, for example), so cannot pool
|
||||
// connection here.
|
||||
// Local file size becomes zero when DiskAdaptor::initAndOpenFile()
|
||||
// is called. So zero-length file is complete if chunked encoding is
|
||||
// not used.
|
||||
if(!chunkedUsed && getDownloadContext()->knowsTotalLength()) {
|
||||
getRequestGroup()->getPieceStorage()->markAllPiecesDone();
|
||||
poolConnection();
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue