From 68b5ae7d86a054ddd5c5d813298240370438d086 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 24 Jun 2008 14:43:27 +0000 Subject: [PATCH] 2008-06-24 Tatsuhiro Tsujikawa If FTP server returns negative response with REST raw command and requested range is not 0, throw exception. If requested range is 0, continue download a file from 0 byte. * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h --- ChangeLog | 8 ++++++++ src/FtpNegotiationCommand.cc | 11 +++++++---- src/FtpNegotiationCommand.h | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a9d1babd..574739fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-06-24 Tatsuhiro Tsujikawa + + If FTP server returns negative response with REST raw command and + requested range is not 0, throw exception. If requested range is 0, + continue download a file from 0 byte. + * src/FtpNegotiationCommand.cc + * src/FtpNegotiationCommand.h + 2008-06-24 Tatsuhiro Tsujikawa Supported FTP server which don't recognize SIZE raw command. diff --git a/src/FtpNegotiationCommand.cc b/src/FtpNegotiationCommand.cc index 72873665..80826481 100644 --- a/src/FtpNegotiationCommand.cc +++ b/src/FtpNegotiationCommand.cc @@ -383,14 +383,17 @@ bool FtpNegotiationCommand::sendRest(const SegmentHandle& segment) { return false; } -bool FtpNegotiationCommand::recvRest() { +bool FtpNegotiationCommand::recvRest(const SharedHandle& segment) { unsigned int status = ftp->receiveResponse(); if(status == 0) { return false; } - // TODO if we recieve negative response, then we set _requestGroup->getSegmentMan()->splittable = false, and continue. + // If we recieve negative response and requested file position is not 0, + // then throw exception here. if(status != 350) { - throw DlAbortEx(StringFormat(EX_BAD_STATUS, status).str()); + if(!segment.isNull() && segment->getPositionToWrite() != 0) { + throw DlAbortEx("FTP server doesn't support resuming."); + } } sequence = SEQ_SEND_RETR; return true; @@ -480,7 +483,7 @@ bool FtpNegotiationCommand::processSequence(const SegmentHandle& segment) { case SEQ_SEND_REST: return sendRest(segment); case SEQ_RECV_REST: - return recvRest(); + return recvRest(segment); case SEQ_SEND_RETR: return sendRetr(); case SEQ_RECV_RETR: diff --git a/src/FtpNegotiationCommand.h b/src/FtpNegotiationCommand.h index 6fd27c9e..084439c6 100644 --- a/src/FtpNegotiationCommand.h +++ b/src/FtpNegotiationCommand.h @@ -92,7 +92,7 @@ private: bool recvPasv(); bool sendRest(const SharedHandle& segment); bool sendRestPasv(const SharedHandle& segment); - bool recvRest(); + bool recvRest(const SharedHandle& segment); bool sendRetr(); bool recvRetr(); bool waitConnection();