From: Amos Jeffries Date: Fri, 24 Apr 2009 05:40:34 +0000 (+1200) Subject: Author: Christos Tsantilas X-Git-Tag: SQUID_3_1_0_8~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=605d58b832a8e57047b5243775ae091312d9d5fb;p=thirdparty%2Fsquid.git Author: Christos Tsantilas Bug 2578: squid fails to resume dowload from FTP The ftp code uses the FtpStateData::restart_offset and FtpStateData::restarted_offset to compute the offset in the case of partial responses, but it must also set the ServerStateData::currentOffset member variable. This patch: - completely removes the FtpStateData::restarted_offset member and uses the ServerStateData::currentOffset member variable instead. - adds the FtpStateData::setCurrentOffset(int64_t) and FtpStateData::getCurrentOffset() public methods to allow set/get the ServerStateData::currentOffset value --- diff --git a/src/ftp.cc b/src/ftp.cc index c6ff911ecd..626b979597 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -168,7 +168,6 @@ public: char *filepath; char *dirpath; int64_t restart_offset; - int64_t restarted_offset; char *proxy_host; size_t list_width; wordlist *cwd_message; @@ -234,6 +233,8 @@ public: void processHeadResponse(); void processReplyBody(); void writeCommand(const char *buf); + void setCurrentOffset(int64_t offset) { currentOffset = offset; } + int64_t getCurrentOffset() const { return currentOffset; } static CNCB ftpPasvCallback; static PF ftpDataWrite; @@ -3125,7 +3126,7 @@ ftpReadRest(FtpStateData * ftpState) assert(ftpState->restart_offset > 0); if (code == 350) { - ftpState->restarted_offset = ftpState->restart_offset; + ftpState->setCurrentOffset(ftpState->restart_offset); ftpSendRetr(ftpState); } else if (code > 0) { debugs(9, 3, HERE << "REST not supported"); @@ -3412,7 +3413,7 @@ void FtpStateData::hackShortcut(FTPSM * nextState) { /* Clear some unwanted state */ - restarted_offset = 0; + setCurrentOffset(0); restart_offset = 0; /* Save old error message & some state info */ @@ -3654,11 +3655,11 @@ FtpStateData::appendSuccessHeader() /* set standard stuff */ HttpVersion version(1, 0); - if (0 == restarted_offset) { + if (0 == getCurrentOffset()) { /* Full reply */ reply->setHeaders(version, HTTP_OK, "Gatewaying", mime_type, theSize, mdtm, -2); - } else if (theSize < restarted_offset) { + } else if (theSize < getCurrentOffset()) { /* * DPW 2007-05-04 * offset should not be larger than theSize. We should @@ -3666,7 +3667,7 @@ FtpStateData::appendSuccessHeader() * send REST if we know the theSize and if it is less than theSize. */ debugs(0,DBG_CRITICAL,HERE << "Whoops! " << - " restarted_offset=" << restarted_offset << + " current offset=" << getCurrentOffset() << ", but theSize=" << theSize << ". assuming full content response"); reply->setHeaders(version, HTTP_OK, "Gatewaying", @@ -3674,10 +3675,10 @@ FtpStateData::appendSuccessHeader() } else { /* Partial reply */ HttpHdrRangeSpec range_spec; - range_spec.offset = restarted_offset; - range_spec.length = theSize - restarted_offset; + range_spec.offset = getCurrentOffset(); + range_spec.length = theSize - getCurrentOffset(); reply->setHeaders(version, HTTP_PARTIAL_CONTENT, "Gatewaying", - mime_type, theSize - restarted_offset, mdtm, -2); + mime_type, theSize - getCurrentOffset(), mdtm, -2); httpHeaderAddContRange(&reply->header, range_spec, theSize); } @@ -3703,7 +3704,7 @@ FtpStateData::haveParsedReplyHeaders() * Authenticated requests can't be cached. */ e->release(); - } else if (EBIT_TEST(e->flags, ENTRY_CACHABLE) && !restarted_offset) { + } else if (EBIT_TEST(e->flags, ENTRY_CACHABLE) && !getCurrentOffset()) { e->setPublicKey(); } else { e->release();