diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-06-09 12:43:44 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-06-09 12:43:44 +0000 |
| commit | 970e7f95a65b1b8940c9131a76372b7d7abffdf1 (patch) | |
| tree | c3a9b7b51a97a01160a7b37989406b78041d9115 /src/CreateRequestCommand.cc | |
| parent | 9afc36152a1ce428243a3ace608d0508716a2efb (diff) | |
2010-06-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Made protected member variable private. Added accessor funcs.
* src/AbstractCommand.cc
* src/AbstractCommand.h
* src/AbstractProxyRequestCommand.cc
* src/AbstractProxyRequestCommand.h
* src/AbstractProxyResponseCommand.cc
* src/AbstractProxyResponseCommand.h
* src/CreateRequestCommand.cc
* src/DownloadCommand.cc
* src/DownloadCommand.h
* src/FtpDownloadCommand.cc
* src/FtpDownloadCommand.h
* src/FtpFinishDownloadCommand.cc
* src/FtpInitiateConnectionCommand.cc
* src/FtpNegotiationCommand.cc
* src/FtpNegotiationCommand.h
* src/FtpTunnelRequestCommand.cc
* src/FtpTunnelResponseCommand.cc
* src/HttpDownloadCommand.cc
* src/HttpInitiateConnectionCommand.cc
* src/HttpProxyRequestCommand.cc
* src/HttpProxyResponseCommand.cc
* src/HttpRequestCommand.cc
* src/HttpResponseCommand.cc
* src/HttpResponseCommand.h
* src/HttpSkipResponseCommand.cc
* src/InitiateConnectionCommand.cc
Diffstat (limited to 'src/CreateRequestCommand.cc')
| -rw-r--r-- | src/CreateRequestCommand.cc | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/CreateRequestCommand.cc b/src/CreateRequestCommand.cc index 40a6c6f6..e519c017 100644 --- a/src/CreateRequestCommand.cc +++ b/src/CreateRequestCommand.cc @@ -67,39 +67,41 @@ CreateRequestCommand::CreateRequestCommand(cuid_t cuid, bool CreateRequestCommand::executeInternal() { - if(_segments.empty()) { - _fileEntry = _requestGroup->getDownloadContext()->findFileEntryByOffset(0); + if(getSegments().empty()) { + setFileEntry(getDownloadContext()->findFileEntryByOffset(0)); } else { // We assume all segments belongs to same file. - _fileEntry = _requestGroup->getDownloadContext()->findFileEntryByOffset - (_segments.front()->getPositionToWrite()); + setFileEntry(getDownloadContext()->findFileEntryByOffset + (getSegments().front()->getPositionToWrite())); } - if(_fileEntry->getRemainingUris().empty() && + if(getFileEntry()->getRemainingUris().empty() && getOption()->getAsBool(PREF_REUSE_URI) && - _fileEntry->countPooledRequest() == 0) { - _fileEntry->reuseUri(_requestGroup->getNumConcurrentCommand()); + getFileEntry()->countPooledRequest() == 0) { + getFileEntry()->reuseUri(getRequestGroup()->getNumConcurrentCommand()); } - req = _fileEntry->getRequest(_requestGroup->getURISelector(), - getOption()->get(PREF_REFERER), - // Don't use HEAD request when file - // size is known. - // Use HEAD for dry-run mode. - (_fileEntry->getLength() == 0 && - getOption()->getAsBool(PREF_USE_HEAD)) || - getOption()->getAsBool(PREF_DRY_RUN)? - Request::METHOD_HEAD:Request::METHOD_GET); - if(req.isNull()) { - if(!_requestGroup->getSegmentMan().isNull()) { - _requestGroup->getSegmentMan()->ignoreSegmentFor(_fileEntry); + setRequest + (getFileEntry()->getRequest(getRequestGroup()->getURISelector(), + getOption()->get(PREF_REFERER), + // Don't use HEAD request when file + // size is known. + // Use HEAD for dry-run mode. + (getFileEntry()->getLength() == 0 && + getOption()->getAsBool(PREF_USE_HEAD)) || + getOption()->getAsBool(PREF_DRY_RUN)? + Request::METHOD_HEAD:Request::METHOD_GET)); + if(getRequest().isNull()) { + if(!getSegmentMan().isNull()) { + getSegmentMan()->ignoreSegmentFor(getFileEntry()); } throw DL_ABORT_EX("No URI available."); } Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand - (getCuid(), req, _fileEntry, _requestGroup, e); - e->setNoWait(true); - e->addCommand(command); + (getCuid(), getRequest(), getFileEntry(), getRequestGroup(), + getDownloadEngine()); + getDownloadEngine()->setNoWait(true); + getDownloadEngine()->addCommand(command); return true; } @@ -113,16 +115,16 @@ bool CreateRequestCommand::prepareForRetry(time_t wait) // called repeatedly. This means that newly created // CreateRequestCommand is deleted one second later: This is not // efficient. For this reason, reuse current CreateRequestCommand. - if(!_requestGroup->getPieceStorage().isNull()) { - _requestGroup->getSegmentMan()->cancelSegment(getCuid()); + if(!getPieceStorage().isNull()) { + getSegmentMan()->cancelSegment(getCuid()); } if(getLogger()->debug()) { getLogger()->debug("CUID#%s - Reusing CreateRequestCommand", util::itos(getCuid()).c_str()); } SleepCommand* scom = new SleepCommand - (getCuid(), e, _requestGroup, this, wait); - e->addCommand(scom); + (getCuid(), getDownloadEngine(), getRequestGroup(), this, wait); + getDownloadEngine()->addCommand(scom); return false; } |
