2006-02-17 13:35:04 +00:00
|
|
|
/* <!-- copyright */
|
|
|
|
/*
|
2006-09-21 15:31:24 +00:00
|
|
|
* aria2 - The high speed download utility
|
2006-02-17 13:35:04 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-09-21 15:31:24 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give
|
|
|
|
* permission to link the code of portions of this program with the
|
|
|
|
* OpenSSL library under certain conditions as described in each
|
|
|
|
* individual source file, and distribute linked combinations
|
|
|
|
* including the two.
|
|
|
|
* You must obey the GNU General Public License in all respects
|
|
|
|
* for all of the code used other than OpenSSL. If you modify
|
|
|
|
* file(s) with this exception, you may extend this exception to your
|
|
|
|
* version of the file(s), but you are not obligated to do so. If you
|
|
|
|
* do not wish to do so, delete this exception statement from your
|
|
|
|
* version. If you delete this exception statement from all source
|
|
|
|
* files in the program, then also delete it here.
|
2006-02-17 13:35:04 +00:00
|
|
|
*/
|
|
|
|
/* copyright --> */
|
|
|
|
#include "AbstractCommand.h"
|
2008-11-09 08:23:11 +00:00
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "Request.h"
|
|
|
|
#include "DownloadEngine.h"
|
|
|
|
#include "Option.h"
|
|
|
|
#include "PeerStat.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "SegmentMan.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "Logger.h"
|
|
|
|
#include "Segment.h"
|
2006-02-17 13:35:04 +00:00
|
|
|
#include "DlAbortEx.h"
|
|
|
|
#include "DlRetryEx.h"
|
2007-11-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Don't connect server before checking file integrity at startup,
if
filesize and output file path are known.
* src/AbstractCommand.cc
* src/StreamFileAllocationEntry.cc
* src/Metalink2RequestGroup.cc
* src/RequestGroup.{h, cc}
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
Added DownloadFailureException. If it is thrown, RequestGroup
should
halt.
* src/AbstractCommand.cc
* src/DownloadFailureException.h
* src/RequestGroup.cc
Catch RecoverableException, instead of DlAbortEx.
* src/RequestGroupMan.cc
* src/FillRequestGroupCommand.cc
* src/MetaFileUtil.cc
* src/IteratableChunkChecksumValidator.cc
Now first parameter of MSG_DOWNLOAD_ABORTED is
gid(RequestGroup::
getGID())
* src/CheckIntegrityCommand.cc
* src/message.h
Print gid instead of idx.
* src/RequestGroupMan.cc
Removed exception throwers declaration.
* src/DirectDiskAdaptor.{h, cc}
* src/SocketCore.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpConnection.{h, cc}
* src/HttpResponse.{h, cc}
* src/DiskAdaptor.{h, cc}
* src/CopyDiskAdaptor.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpHeaderProcessor.{h, cc}
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/Util.{h, cc}
* test/UtilTest.cc
* src/DefaultDiskWriter.{h, cc}
* src/FtpConnection.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Removed duplicate code.
* src/StreamCheckIntegrityEntry.cc
Removed unnecessary include.
* src/DiskWriter.h
Included Exception.h
* src/option_processing.cc
Included 2 files and added doc
* src/TrackerWatcherCommand.cc
* src/SocketCore.cc (writeData): Fixed send error with GnuTLS.
2007-11-09 18:01:12 +00:00
|
|
|
#include "DownloadFailureException.h"
|
2009-06-23 15:35:45 +00:00
|
|
|
#include "CreateRequestCommand.h"
|
2009-06-29 15:18:21 +00:00
|
|
|
#include "InitiateConnectionCommandFactory.h"
|
2006-02-18 05:13:21 +00:00
|
|
|
#include "SleepCommand.h"
|
2008-05-08 11:18:36 +00:00
|
|
|
#ifdef ENABLE_ASYNC_DNS
|
|
|
|
#include "AsyncNameResolver.h"
|
|
|
|
#endif // ENABLE_ASYNC_DNS
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "StreamCheckIntegrityEntry.h"
|
2007-11-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Don't connect server before checking file integrity at startup,
if
filesize and output file path are known.
* src/AbstractCommand.cc
* src/StreamFileAllocationEntry.cc
* src/Metalink2RequestGroup.cc
* src/RequestGroup.{h, cc}
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
Added DownloadFailureException. If it is thrown, RequestGroup
should
halt.
* src/AbstractCommand.cc
* src/DownloadFailureException.h
* src/RequestGroup.cc
Catch RecoverableException, instead of DlAbortEx.
* src/RequestGroupMan.cc
* src/FillRequestGroupCommand.cc
* src/MetaFileUtil.cc
* src/IteratableChunkChecksumValidator.cc
Now first parameter of MSG_DOWNLOAD_ABORTED is
gid(RequestGroup::
getGID())
* src/CheckIntegrityCommand.cc
* src/message.h
Print gid instead of idx.
* src/RequestGroupMan.cc
Removed exception throwers declaration.
* src/DirectDiskAdaptor.{h, cc}
* src/SocketCore.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpConnection.{h, cc}
* src/HttpResponse.{h, cc}
* src/DiskAdaptor.{h, cc}
* src/CopyDiskAdaptor.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpHeaderProcessor.{h, cc}
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/Util.{h, cc}
* test/UtilTest.cc
* src/DefaultDiskWriter.{h, cc}
* src/FtpConnection.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Removed duplicate code.
* src/StreamCheckIntegrityEntry.cc
Removed unnecessary include.
* src/DiskWriter.h
Included Exception.h
* src/option_processing.cc
Included 2 files and added doc
* src/TrackerWatcherCommand.cc
* src/SocketCore.cc (writeData): Fixed send error with GnuTLS.
2007-11-09 18:01:12 +00:00
|
|
|
#include "PieceStorage.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "Socket.h"
|
|
|
|
#include "message.h"
|
|
|
|
#include "prefs.h"
|
2008-04-27 02:22:14 +00:00
|
|
|
#include "StringFormat.h"
|
2008-08-04 17:06:47 +00:00
|
|
|
#include "ServerStat.h"
|
|
|
|
#include "RequestGroupMan.h"
|
2008-11-04 14:08:26 +00:00
|
|
|
#include "A2STR.h"
|
2008-11-09 08:23:11 +00:00
|
|
|
#include "Util.h"
|
2009-06-23 15:35:45 +00:00
|
|
|
#include "LogFactory.h"
|
|
|
|
#include "DownloadContext.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
namespace aria2 {
|
2006-02-17 13:35:04 +00:00
|
|
|
|
2009-06-23 15:35:45 +00:00
|
|
|
AbstractCommand::AbstractCommand(int32_t cuid,
|
|
|
|
const SharedHandle<Request>& req,
|
|
|
|
const SharedHandle<FileEntry>& fileEntry,
|
|
|
|
RequestGroup* requestGroup,
|
|
|
|
DownloadEngine* e,
|
|
|
|
const SocketHandle& s):
|
|
|
|
Command(cuid), _requestGroup(requestGroup),
|
|
|
|
req(req), _fileEntry(fileEntry), e(e), socket(s),
|
|
|
|
checkSocketIsReadable(false), checkSocketIsWritable(false),
|
|
|
|
nameResolverCheck(false)
|
|
|
|
{
|
|
|
|
if(!socket.isNull() && socket->isOpen()) {
|
|
|
|
setReadCheckSocket(socket);
|
|
|
|
}
|
|
|
|
timeout = _requestGroup->getTimeout();
|
|
|
|
_requestGroup->increaseStreamConnection();
|
|
|
|
_requestGroup->increaseNumCommand();
|
|
|
|
}
|
|
|
|
|
2006-02-17 13:35:04 +00:00
|
|
|
AbstractCommand::~AbstractCommand() {
|
2006-07-19 17:07:45 +00:00
|
|
|
disableReadCheckSocket();
|
|
|
|
disableWriteCheckSocket();
|
2008-05-08 11:18:36 +00:00
|
|
|
#ifdef ENABLE_ASYNC_DNS
|
|
|
|
disableNameResolverCheck(_asyncNameResolver);
|
|
|
|
#endif // ENABLE_ASYNC_DNS
|
2009-04-23 15:00:09 +00:00
|
|
|
_requestGroup->decreaseNumCommand();
|
2007-10-11 16:58:24 +00:00
|
|
|
_requestGroup->decreaseStreamConnection();
|
2006-02-17 13:35:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AbstractCommand::execute() {
|
2008-09-23 10:50:00 +00:00
|
|
|
logger->debug("CUID#%d - socket: read:%d, write:%d, hup:%d, err:%d",
|
|
|
|
cuid, _readEvent, _writeEvent, _hupEvent, _errorEvent);
|
2006-02-17 13:35:04 +00:00
|
|
|
try {
|
2007-10-11 16:58:24 +00:00
|
|
|
if(_requestGroup->downloadFinished() || _requestGroup->isHaltRequested()) {
|
2007-07-20 17:06:21 +00:00
|
|
|
//logger->debug("CUID#%d - finished.", cuid);
|
2006-09-21 06:56:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-07-15 11:58:27 +00:00
|
|
|
// TODO it is not needed to check other PeerStats every time.
|
2009-06-29 15:18:21 +00:00
|
|
|
// Find faster Request when this is the only active Request
|
|
|
|
if(!req.isNull() && _requestGroup->getNumStreamConnection() == 1 &&
|
|
|
|
_fileEntry->countPooledRequest() > 0) {
|
|
|
|
SharedHandle<Request> fasterRequest = _fileEntry->findFasterRequest(req);
|
|
|
|
if(!fasterRequest.isNull()) {
|
|
|
|
logger->info("CUID#%d - Use faster Request hostname=%s, port=%u",
|
|
|
|
cuid,
|
|
|
|
fasterRequest->getHost().c_str(),
|
|
|
|
fasterRequest->getPort());
|
|
|
|
|
|
|
|
// Cancel current Request object and use faster one.
|
|
|
|
_fileEntry->removeRequest(req);
|
|
|
|
Command* command =
|
|
|
|
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
|
|
|
(cuid, fasterRequest, _fileEntry, _requestGroup, e);
|
|
|
|
e->setNoWait(true);
|
|
|
|
e->commands.push_back(command);
|
2006-09-21 06:56:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2008-05-31 10:31:07 +00:00
|
|
|
if((checkSocketIsReadable && _readEvent) ||
|
|
|
|
(checkSocketIsWritable && _writeEvent) ||
|
2008-09-14 13:43:34 +00:00
|
|
|
_hupEvent ||
|
2006-10-01 11:29:14 +00:00
|
|
|
#ifdef ENABLE_ASYNC_DNS
|
2008-03-15 04:19:46 +00:00
|
|
|
(nameResolverCheck && nameResolveFinished()) ||
|
2006-10-01 11:29:14 +00:00
|
|
|
#endif // ENABLE_ASYNC_DNS
|
2008-03-15 04:19:46 +00:00
|
|
|
(!checkSocketIsReadable && !checkSocketIsWritable && !nameResolverCheck)) {
|
2006-06-12 16:55:08 +00:00
|
|
|
checkPoint.reset();
|
2007-10-11 16:58:24 +00:00
|
|
|
if(!_requestGroup->getPieceStorage().isNull()) {
|
2008-05-11 10:46:52 +00:00
|
|
|
_segments.clear();
|
|
|
|
_requestGroup->getSegmentMan()->getInFlightSegment(_segments, cuid);
|
2009-07-01 13:26:58 +00:00
|
|
|
if(req.isNull() || req->getMaxPipelinedRequest() == 1 ||
|
|
|
|
_requestGroup->getDownloadContext()->getFileEntries().size() == 1) {
|
2009-06-30 17:03:57 +00:00
|
|
|
if(_segments.empty()) {
|
|
|
|
SharedHandle<Segment> segment =
|
|
|
|
_requestGroup->getSegmentMan()->getSegment(cuid);
|
|
|
|
if(!segment.isNull()) {
|
|
|
|
_segments.push_back(segment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(_segments.empty()) {
|
|
|
|
// TODO socket could be pooled here if pipelining is enabled...
|
|
|
|
logger->info(MSG_NO_SEGMENT_AVAILABLE, cuid);
|
2009-07-13 15:02:32 +00:00
|
|
|
// When all segments are ignored in SegmentMan, there are
|
|
|
|
// no URIs available, so don't retry.
|
|
|
|
if(_requestGroup->getSegmentMan()->allSegmentsIgnored()) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return prepareForRetry(1);
|
|
|
|
}
|
2009-06-30 17:03:57 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
size_t maxSegments = req->getMaxPipelinedRequest();
|
|
|
|
if(_segments.size() < maxSegments) {
|
|
|
|
_requestGroup->getSegmentMan()->getSegment
|
|
|
|
(_segments, cuid, _fileEntry, maxSegments);
|
|
|
|
}
|
|
|
|
if(_segments.empty()) {
|
|
|
|
return prepareForRetry(0);
|
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
2007-03-15 15:07:18 +00:00
|
|
|
}
|
2006-05-18 17:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
2007-03-15 15:07:18 +00:00
|
|
|
return executeInternal();
|
2008-09-14 13:43:34 +00:00
|
|
|
} else if(_errorEvent) {
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_RETRY_EX
|
2008-09-14 14:31:19 +00:00
|
|
|
(StringFormat(MSG_NETWORK_PROBLEM,
|
|
|
|
socket->getSocketError().c_str()).str());
|
2006-05-18 17:08:29 +00:00
|
|
|
} else {
|
2006-06-12 16:55:08 +00:00
|
|
|
if(checkPoint.elapsed(timeout)) {
|
2008-08-04 17:06:47 +00:00
|
|
|
// timeout triggers ServerStat error state.
|
2009-06-23 15:35:45 +00:00
|
|
|
|
2008-08-04 17:06:47 +00:00
|
|
|
SharedHandle<ServerStat> ss =
|
2008-09-14 14:31:19 +00:00
|
|
|
e->_requestGroupMan->getOrCreateServerStat(req->getHost(),
|
|
|
|
req->getProtocol());
|
2008-08-04 17:06:47 +00:00
|
|
|
ss->setError();
|
|
|
|
|
2009-06-29 08:42:58 +00:00
|
|
|
throw DL_RETRY_EX2(EX_TIME_OUT, downloadresultcode::TIME_OUT);
|
2006-02-17 13:35:04 +00:00
|
|
|
}
|
2006-05-09 15:54:14 +00:00
|
|
|
e->commands.push_back(this);
|
2006-02-17 13:35:04 +00:00
|
|
|
return false;
|
|
|
|
}
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(DlAbortEx& err) {
|
2009-06-23 15:35:45 +00:00
|
|
|
if(req.isNull()) {
|
|
|
|
logger->debug(EX_EXCEPTION_CAUGHT, err);
|
|
|
|
} else {
|
|
|
|
logger->error(MSG_DOWNLOAD_ABORTED,
|
|
|
|
DL_ABORT_EX2(StringFormat
|
|
|
|
("URI=%s", req->getCurrentUrl().c_str()).str(),err),
|
|
|
|
cuid, req->getUrl().c_str());
|
2009-06-29 08:42:58 +00:00
|
|
|
_fileEntry->addURIResult(req->getUrl(), err.getCode());
|
|
|
|
_requestGroup->setLastUriResult(req->getUrl(), err.getCode());
|
2009-06-23 15:35:45 +00:00
|
|
|
}
|
2008-04-27 02:22:14 +00:00
|
|
|
onAbort();
|
2006-07-03 14:19:23 +00:00
|
|
|
tryReserved();
|
2006-02-17 13:35:04 +00:00
|
|
|
return true;
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(DlRetryEx& err) {
|
2009-07-11 10:25:45 +00:00
|
|
|
assert(!req.isNull());
|
2009-03-13 12:58:58 +00:00
|
|
|
logger->info(MSG_RESTARTING_DOWNLOAD,
|
2009-05-18 15:07:15 +00:00
|
|
|
DL_RETRY_EX2(StringFormat
|
|
|
|
("URI=%s", req->getCurrentUrl().c_str()).str(),err),
|
2009-03-13 12:58:58 +00:00
|
|
|
cuid, req->getUrl().c_str());
|
2006-02-21 12:27:17 +00:00
|
|
|
req->addTryCount();
|
2008-06-17 09:09:31 +00:00
|
|
|
req->resetRedirectCount();
|
2009-06-12 14:12:54 +00:00
|
|
|
const unsigned int maxTries = getOption()->getAsInt(PREF_MAX_TRIES);
|
|
|
|
bool isAbort = maxTries != 0 && req->getTryCount() >= maxTries;
|
2006-03-01 02:26:29 +00:00
|
|
|
if(isAbort) {
|
2008-04-27 02:22:14 +00:00
|
|
|
onAbort();
|
2007-06-10 07:55:43 +00:00
|
|
|
logger->info(MSG_MAX_TRY, cuid, req->getTryCount());
|
|
|
|
logger->error(MSG_DOWNLOAD_ABORTED, err, cuid, req->getUrl().c_str());
|
2009-06-29 08:42:58 +00:00
|
|
|
_fileEntry->addURIResult(req->getUrl(), err.getCode());
|
|
|
|
_requestGroup->setLastUriResult(req->getUrl(), err.getCode());
|
2006-07-03 14:19:23 +00:00
|
|
|
tryReserved();
|
2006-02-17 13:35:04 +00:00
|
|
|
return true;
|
|
|
|
} else {
|
2009-05-08 16:41:21 +00:00
|
|
|
return prepareForRetry(getOption()->getAsInt(PREF_RETRY_WAIT));
|
2006-02-17 13:35:04 +00:00
|
|
|
}
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(DownloadFailureException& err) {
|
2007-11-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Don't connect server before checking file integrity at startup,
if
filesize and output file path are known.
* src/AbstractCommand.cc
* src/StreamFileAllocationEntry.cc
* src/Metalink2RequestGroup.cc
* src/RequestGroup.{h, cc}
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
Added DownloadFailureException. If it is thrown, RequestGroup
should
halt.
* src/AbstractCommand.cc
* src/DownloadFailureException.h
* src/RequestGroup.cc
Catch RecoverableException, instead of DlAbortEx.
* src/RequestGroupMan.cc
* src/FillRequestGroupCommand.cc
* src/MetaFileUtil.cc
* src/IteratableChunkChecksumValidator.cc
Now first parameter of MSG_DOWNLOAD_ABORTED is
gid(RequestGroup::
getGID())
* src/CheckIntegrityCommand.cc
* src/message.h
Print gid instead of idx.
* src/RequestGroupMan.cc
Removed exception throwers declaration.
* src/DirectDiskAdaptor.{h, cc}
* src/SocketCore.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpConnection.{h, cc}
* src/HttpResponse.{h, cc}
* src/DiskAdaptor.{h, cc}
* src/CopyDiskAdaptor.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpHeaderProcessor.{h, cc}
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/Util.{h, cc}
* test/UtilTest.cc
* src/DefaultDiskWriter.{h, cc}
* src/FtpConnection.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Removed duplicate code.
* src/StreamCheckIntegrityEntry.cc
Removed unnecessary include.
* src/DiskWriter.h
Included Exception.h
* src/option_processing.cc
Included 2 files and added doc
* src/TrackerWatcherCommand.cc
* src/SocketCore.cc (writeData): Fixed send error with GnuTLS.
2007-11-09 18:01:12 +00:00
|
|
|
logger->error(EX_EXCEPTION_CAUGHT, err);
|
2009-07-11 10:25:45 +00:00
|
|
|
if(!req.isNull()) {
|
|
|
|
_fileEntry->addURIResult(req->getUrl(), err.getCode());
|
|
|
|
_requestGroup->setLastUriResult(req->getUrl(), err.getCode());
|
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
_requestGroup->setHaltRequested(true);
|
|
|
|
return true;
|
2006-02-17 13:35:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-03 14:19:23 +00:00
|
|
|
void AbstractCommand::tryReserved() {
|
2009-06-28 10:37:15 +00:00
|
|
|
if(_requestGroup->getDownloadContext()->getFileEntries().size() == 1) {
|
2009-06-23 15:35:45 +00:00
|
|
|
const SharedHandle<FileEntry>& entry =
|
2009-06-28 10:37:15 +00:00
|
|
|
_requestGroup->getDownloadContext()->getFirstFileEntry();
|
2009-06-23 15:35:45 +00:00
|
|
|
// Don't create new command if currently file length is unknown
|
|
|
|
// and there are no URI left. Because file length is unknown, we
|
|
|
|
// can assume that there are no in-flight request object.
|
2009-07-14 13:11:13 +00:00
|
|
|
if(entry->getLength() == 0 && entry->getRemainingUris().empty()) {
|
2009-07-17 10:27:45 +00:00
|
|
|
logger->debug("CUID#%d - Not trying next request."
|
|
|
|
" No reserved/pooled request is remaining and"
|
|
|
|
" total length is still unknown.", cuid);
|
2009-06-23 15:35:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2009-07-17 10:27:45 +00:00
|
|
|
logger->debug("CUID#%d - Trying reserved/pooled request.", cuid);
|
2008-05-11 09:36:39 +00:00
|
|
|
Commands commands;
|
|
|
|
_requestGroup->createNextCommand(commands, e, 1);
|
2008-09-13 15:54:52 +00:00
|
|
|
e->setNoWait(true);
|
2007-05-20 13:51:52 +00:00
|
|
|
e->addCommand(commands);
|
2006-07-03 14:19:23 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
bool AbstractCommand::prepareForRetry(time_t wait) {
|
2007-10-11 16:58:24 +00:00
|
|
|
if(!_requestGroup->getPieceStorage().isNull()) {
|
|
|
|
_requestGroup->getSegmentMan()->cancelSegment(cuid);
|
|
|
|
}
|
2009-06-23 15:35:45 +00:00
|
|
|
if(!req.isNull()) {
|
|
|
|
_fileEntry->poolRequest(req);
|
|
|
|
logger->debug("CUID#%d - Pooling request URI=%s",
|
|
|
|
cuid, req->getUrl().c_str());
|
2009-06-30 17:03:57 +00:00
|
|
|
if(!_requestGroup->getSegmentMan().isNull()) {
|
|
|
|
_requestGroup->getSegmentMan()->recognizeSegmentFor(_fileEntry);
|
|
|
|
}
|
2009-06-23 15:35:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Command* command = new CreateRequestCommand(cuid, _requestGroup, e);
|
2006-02-18 05:13:21 +00:00
|
|
|
if(wait == 0) {
|
2008-04-20 05:42:15 +00:00
|
|
|
e->setNoWait(true);
|
2006-05-09 15:54:14 +00:00
|
|
|
e->commands.push_back(command);
|
2006-02-18 05:13:21 +00:00
|
|
|
} else {
|
2008-11-11 16:05:42 +00:00
|
|
|
SleepCommand* scom = new SleepCommand(cuid, e, _requestGroup,
|
|
|
|
command, wait);
|
2006-05-09 15:54:14 +00:00
|
|
|
e->commands.push_back(scom);
|
2006-02-18 05:13:21 +00:00
|
|
|
}
|
2006-02-17 13:35:04 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-04-27 02:22:14 +00:00
|
|
|
void AbstractCommand::onAbort() {
|
2009-06-23 15:35:45 +00:00
|
|
|
if(!req.isNull()) {
|
|
|
|
logger->debug(req->getCurrentUrl().c_str());
|
|
|
|
// TODO This might be a problem if the failure is caused by proxy.
|
|
|
|
e->_requestGroupMan->getOrCreateServerStat(req->getHost(),
|
|
|
|
req->getProtocol())->setError();
|
2009-06-29 08:42:58 +00:00
|
|
|
_fileEntry->removeIdenticalURI(req->getUrl());
|
2009-06-23 15:35:45 +00:00
|
|
|
_fileEntry->removeRequest(req);
|
|
|
|
}
|
2009-03-07 14:24:50 +00:00
|
|
|
|
2009-07-17 10:27:45 +00:00
|
|
|
logger->debug("CUID#%d - Aborting download", cuid);
|
2007-10-11 16:58:24 +00:00
|
|
|
if(!_requestGroup->getPieceStorage().isNull()) {
|
|
|
|
_requestGroup->getSegmentMan()->cancelSegment(cuid);
|
|
|
|
}
|
2006-02-21 12:27:17 +00:00
|
|
|
}
|
|
|
|
|
2006-07-19 17:07:45 +00:00
|
|
|
void AbstractCommand::disableReadCheckSocket() {
|
|
|
|
if(checkSocketIsReadable) {
|
2006-08-14 15:03:38 +00:00
|
|
|
e->deleteSocketForReadCheck(readCheckTarget, this);
|
2006-07-19 17:07:45 +00:00
|
|
|
checkSocketIsReadable = false;
|
|
|
|
readCheckTarget = SocketHandle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AbstractCommand::setReadCheckSocket(const SocketHandle& socket) {
|
|
|
|
if(!socket->isOpen()) {
|
|
|
|
disableReadCheckSocket();
|
2006-02-21 12:27:17 +00:00
|
|
|
} else {
|
|
|
|
if(checkSocketIsReadable) {
|
|
|
|
if(readCheckTarget != socket) {
|
2006-08-14 15:03:38 +00:00
|
|
|
e->deleteSocketForReadCheck(readCheckTarget, this);
|
|
|
|
e->addSocketForReadCheck(socket, this);
|
2006-02-21 12:27:17 +00:00
|
|
|
readCheckTarget = socket;
|
|
|
|
}
|
|
|
|
} else {
|
2006-08-14 15:03:38 +00:00
|
|
|
e->addSocketForReadCheck(socket, this);
|
2006-02-21 12:27:17 +00:00
|
|
|
checkSocketIsReadable = true;
|
|
|
|
readCheckTarget = socket;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-27 16:06:34 +00:00
|
|
|
void AbstractCommand::setReadCheckSocketIf
|
|
|
|
(const SharedHandle<SocketCore>& socket, bool pred)
|
|
|
|
{
|
|
|
|
if(pred) {
|
|
|
|
setReadCheckSocket(socket);
|
|
|
|
} else {
|
|
|
|
disableReadCheckSocket();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-19 17:07:45 +00:00
|
|
|
void AbstractCommand::disableWriteCheckSocket() {
|
|
|
|
if(checkSocketIsWritable) {
|
2006-08-14 15:03:38 +00:00
|
|
|
e->deleteSocketForWriteCheck(writeCheckTarget, this);
|
2006-07-19 17:07:45 +00:00
|
|
|
checkSocketIsWritable = false;
|
|
|
|
writeCheckTarget = SocketHandle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AbstractCommand::setWriteCheckSocket(const SocketHandle& socket) {
|
|
|
|
if(!socket->isOpen()) {
|
|
|
|
disableWriteCheckSocket();
|
2006-02-21 12:27:17 +00:00
|
|
|
} else {
|
|
|
|
if(checkSocketIsWritable) {
|
|
|
|
if(writeCheckTarget != socket) {
|
2006-08-14 15:03:38 +00:00
|
|
|
e->deleteSocketForWriteCheck(writeCheckTarget, this);
|
|
|
|
e->addSocketForWriteCheck(socket, this);
|
2006-02-21 12:27:17 +00:00
|
|
|
writeCheckTarget = socket;
|
|
|
|
}
|
|
|
|
} else {
|
2006-08-14 15:03:38 +00:00
|
|
|
e->addSocketForWriteCheck(socket, this);
|
2006-02-21 12:27:17 +00:00
|
|
|
checkSocketIsWritable = true;
|
|
|
|
writeCheckTarget = socket;
|
|
|
|
}
|
|
|
|
}
|
2006-02-17 13:35:04 +00:00
|
|
|
}
|
2006-08-11 12:29:55 +00:00
|
|
|
|
2008-09-27 16:06:34 +00:00
|
|
|
void AbstractCommand::setWriteCheckSocketIf
|
|
|
|
(const SharedHandle<SocketCore>& socket, bool pred)
|
|
|
|
{
|
|
|
|
if(pred) {
|
|
|
|
setWriteCheckSocket(socket);
|
|
|
|
} else {
|
|
|
|
disableWriteCheckSocket();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-04 14:08:26 +00:00
|
|
|
static const std::string& getProxyStringFor(const std::string& proxyPref,
|
2009-05-08 16:41:21 +00:00
|
|
|
const SharedHandle<Option>& option)
|
2008-11-04 14:08:26 +00:00
|
|
|
{
|
|
|
|
if(option->defined(proxyPref)) {
|
|
|
|
return option->get(proxyPref);
|
|
|
|
} else {
|
|
|
|
return option->get(PREF_ALL_PROXY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isProxyUsed(const std::string& proxyPref,
|
2009-05-08 16:41:21 +00:00
|
|
|
const SharedHandle<Option>& option)
|
2008-11-04 14:08:26 +00:00
|
|
|
{
|
|
|
|
std::string proxy = getProxyStringFor(proxyPref, option);
|
|
|
|
if(proxy.empty()) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return Request().setUrl(proxy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-08 16:41:21 +00:00
|
|
|
static bool isProxyRequest(const std::string& protocol,
|
|
|
|
const SharedHandle<Option>& option)
|
2008-09-16 10:57:27 +00:00
|
|
|
{
|
|
|
|
return
|
2008-11-04 14:08:26 +00:00
|
|
|
(protocol == Request::PROTO_HTTP && isProxyUsed(PREF_HTTP_PROXY, option)) ||
|
|
|
|
(protocol == Request::PROTO_HTTPS && isProxyUsed(PREF_HTTPS_PROXY,option))||
|
|
|
|
(protocol == Request::PROTO_FTP && isProxyUsed(PREF_FTP_PROXY, option));
|
|
|
|
}
|
|
|
|
|
2008-11-09 08:23:11 +00:00
|
|
|
class DomainMatch {
|
|
|
|
private:
|
|
|
|
std::string _hostname;
|
|
|
|
public:
|
|
|
|
DomainMatch(const std::string& hostname):_hostname(hostname) {}
|
|
|
|
|
|
|
|
bool operator()(const std::string& domain) const
|
|
|
|
{
|
|
|
|
if(Util::startsWith(domain, ".")) {
|
|
|
|
return Util::endsWith(_hostname, domain);
|
|
|
|
} else {
|
|
|
|
return Util::endsWith(_hostname, "."+domain);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool inNoProxy(const SharedHandle<Request>& req,
|
|
|
|
const std::string& noProxy)
|
|
|
|
{
|
|
|
|
std::deque<std::string> entries;
|
|
|
|
Util::slice(entries, noProxy, ',', true);
|
|
|
|
if(entries.empty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return
|
|
|
|
std::find_if(entries.begin(), entries.end(),
|
|
|
|
DomainMatch("."+req->getHost())) != entries.end();
|
|
|
|
}
|
|
|
|
|
2008-11-04 14:08:26 +00:00
|
|
|
bool AbstractCommand::isProxyDefined() const
|
|
|
|
{
|
2009-05-08 16:41:21 +00:00
|
|
|
return isProxyRequest(req->getProtocol(), getOption()) &&
|
|
|
|
!inNoProxy(req, getOption()->get(PREF_NO_PROXY));
|
2008-11-04 14:08:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const std::string& getProxyString(const SharedHandle<Request>& req,
|
2009-05-08 16:41:21 +00:00
|
|
|
const SharedHandle<Option>& option)
|
2008-11-04 14:08:26 +00:00
|
|
|
{
|
|
|
|
if(req->getProtocol() == Request::PROTO_HTTP) {
|
|
|
|
return getProxyStringFor(PREF_HTTP_PROXY, option);
|
|
|
|
} else if(req->getProtocol() == Request::PROTO_HTTPS) {
|
|
|
|
return getProxyStringFor(PREF_HTTPS_PROXY, option);
|
|
|
|
} else if(req->getProtocol() == Request::PROTO_FTP) {
|
|
|
|
return getProxyStringFor(PREF_FTP_PROXY, option);
|
|
|
|
} else {
|
|
|
|
return A2STR::NIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SharedHandle<Request> AbstractCommand::createProxyRequest() const
|
|
|
|
{
|
|
|
|
SharedHandle<Request> proxyRequest;
|
2009-05-08 16:41:21 +00:00
|
|
|
if(inNoProxy(req, getOption()->get(PREF_NO_PROXY))) {
|
2008-11-09 08:23:11 +00:00
|
|
|
return proxyRequest;
|
|
|
|
}
|
2009-05-08 16:41:21 +00:00
|
|
|
std::string proxy = getProxyString(req, getOption());
|
2008-11-04 14:08:26 +00:00
|
|
|
if(!proxy.empty()) {
|
|
|
|
proxyRequest.reset(new Request());
|
|
|
|
if(proxyRequest->setUrl(proxy)) {
|
|
|
|
logger->debug("CUID#%d - Using proxy", cuid);
|
|
|
|
} else {
|
|
|
|
logger->debug("CUID#%d - Failed to parse proxy string", cuid);
|
|
|
|
proxyRequest.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return proxyRequest;
|
2008-09-16 10:57:27 +00:00
|
|
|
}
|
|
|
|
|
2007-03-28 15:08:22 +00:00
|
|
|
#ifdef ENABLE_ASYNC_DNS
|
2008-05-08 11:18:36 +00:00
|
|
|
|
|
|
|
bool AbstractCommand::isAsyncNameResolverInitialized() const
|
|
|
|
{
|
|
|
|
return !_asyncNameResolver.isNull();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AbstractCommand::initAsyncNameResolver(const std::string& hostname)
|
|
|
|
{
|
|
|
|
_asyncNameResolver.reset(new AsyncNameResolver());
|
|
|
|
logger->info(MSG_RESOLVING_HOSTNAME, cuid, hostname.c_str());
|
|
|
|
_asyncNameResolver->resolve(hostname);
|
|
|
|
setNameResolverCheck(_asyncNameResolver);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AbstractCommand::asyncResolveHostname()
|
|
|
|
{
|
|
|
|
switch(_asyncNameResolver->getStatus()) {
|
|
|
|
case AsyncNameResolver::STATUS_SUCCESS:
|
2007-03-28 15:08:22 +00:00
|
|
|
return true;
|
2008-05-08 11:18:36 +00:00
|
|
|
case AsyncNameResolver::STATUS_ERROR:
|
2009-05-08 16:41:21 +00:00
|
|
|
if(!isProxyRequest(req->getProtocol(), getOption())) {
|
2008-09-14 14:31:19 +00:00
|
|
|
e->_requestGroupMan->getOrCreateServerStat
|
|
|
|
(req->getHost(), req->getProtocol())->setError();
|
|
|
|
}
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX(StringFormat(MSG_NAME_RESOLUTION_FAILED, cuid,
|
2008-05-08 11:18:36 +00:00
|
|
|
_asyncNameResolver->getHostname().c_str(),
|
|
|
|
_asyncNameResolver->getError().c_str()).str());
|
|
|
|
default:
|
|
|
|
return false;
|
2007-03-28 15:08:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-08 11:18:36 +00:00
|
|
|
const std::deque<std::string>& AbstractCommand::getResolvedAddresses()
|
|
|
|
{
|
|
|
|
return _asyncNameResolver->getResolvedAddresses();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AbstractCommand::setNameResolverCheck
|
|
|
|
(const SharedHandle<AsyncNameResolver>& resolver) {
|
|
|
|
if(!resolver.isNull()) {
|
|
|
|
nameResolverCheck = true;
|
|
|
|
e->addNameResolverCheck(resolver, this);
|
|
|
|
}
|
2006-08-11 12:29:55 +00:00
|
|
|
}
|
|
|
|
|
2008-05-08 11:18:36 +00:00
|
|
|
void AbstractCommand::disableNameResolverCheck
|
|
|
|
(const SharedHandle<AsyncNameResolver>& resolver) {
|
|
|
|
if(!resolver.isNull()) {
|
|
|
|
nameResolverCheck = false;
|
|
|
|
e->deleteNameResolverCheck(resolver, this);
|
|
|
|
}
|
2006-08-11 12:29:55 +00:00
|
|
|
}
|
|
|
|
|
2006-10-01 11:29:14 +00:00
|
|
|
bool AbstractCommand::nameResolveFinished() const {
|
2008-05-08 11:18:36 +00:00
|
|
|
return
|
|
|
|
_asyncNameResolver->getStatus() == AsyncNameResolver::STATUS_SUCCESS ||
|
|
|
|
_asyncNameResolver->getStatus() == AsyncNameResolver::STATUS_ERROR;
|
2006-10-01 11:29:14 +00:00
|
|
|
}
|
2006-08-21 13:18:51 +00:00
|
|
|
#endif // ENABLE_ASYNC_DNS
|
2007-10-11 16:58:24 +00:00
|
|
|
|
|
|
|
void AbstractCommand::prepareForNextAction(Command* nextCommand)
|
|
|
|
{
|
2009-06-28 10:48:26 +00:00
|
|
|
CheckIntegrityEntryHandle entry
|
|
|
|
(new StreamCheckIntegrityEntry(_requestGroup, nextCommand));
|
2008-05-11 09:36:39 +00:00
|
|
|
|
|
|
|
std::deque<Command*> commands;
|
|
|
|
_requestGroup->processCheckIntegrityEntry(commands, entry, e);
|
|
|
|
|
|
|
|
e->addCommand(commands);
|
2008-04-20 05:42:15 +00:00
|
|
|
e->setNoWait(true);
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
2009-07-02 15:18:13 +00:00
|
|
|
bool AbstractCommand::checkIfConnectionEstablished
|
|
|
|
(const SharedHandle<SocketCore>& socket,
|
|
|
|
const std::string& connectedHostname,
|
|
|
|
const std::string& connectedAddr,
|
|
|
|
uint16_t connectedPort)
|
2008-09-14 14:31:19 +00:00
|
|
|
{
|
|
|
|
if(socket->isReadable(0)) {
|
|
|
|
std::string error = socket->getSocketError();
|
|
|
|
if(!error.empty()) {
|
2009-07-02 15:18:13 +00:00
|
|
|
e->markBadIPAddress(connectedHostname, connectedAddr, connectedPort);
|
|
|
|
if(!e->findCachedIPAddress(connectedHostname, connectedPort).empty()) {
|
|
|
|
logger->info("CUID#%d - Could not to connect to %s:%u."
|
|
|
|
" Trying another address",
|
|
|
|
cuid, connectedAddr.c_str(), connectedPort);
|
|
|
|
Command* command =
|
|
|
|
InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
|
|
|
(cuid, req, _fileEntry, _requestGroup, e);
|
|
|
|
e->setNoWait(true);
|
|
|
|
e->commands.push_back(command);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
e->removeCachedIPAddress(connectedHostname, connectedPort);
|
2008-09-14 14:31:19 +00:00
|
|
|
// Don't set error if proxy server is used and its method is GET.
|
2009-02-07 13:46:08 +00:00
|
|
|
if(resolveProxyMethod(req->getProtocol()) != V_GET ||
|
2009-05-08 16:41:21 +00:00
|
|
|
!isProxyRequest(req->getProtocol(), getOption())) {
|
2008-09-14 14:31:19 +00:00
|
|
|
e->_requestGroupMan->getOrCreateServerStat
|
|
|
|
(req->getHost(), req->getProtocol())->setError();
|
|
|
|
}
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_RETRY_EX
|
2008-09-14 14:31:19 +00:00
|
|
|
(StringFormat(MSG_ESTABLISHING_CONNECTION_FAILED, error.c_str()).str());
|
|
|
|
}
|
|
|
|
}
|
2009-07-02 15:18:13 +00:00
|
|
|
return true;
|
2008-09-14 14:31:19 +00:00
|
|
|
}
|
|
|
|
|
2009-02-07 13:46:08 +00:00
|
|
|
const std::string& AbstractCommand::resolveProxyMethod
|
|
|
|
(const std::string& protocol) const
|
|
|
|
{
|
2009-05-08 16:41:21 +00:00
|
|
|
if(getOption()->get(PREF_PROXY_METHOD) == V_TUNNEL ||
|
2009-02-07 13:46:08 +00:00
|
|
|
Request::PROTO_HTTPS == protocol) {
|
|
|
|
return V_TUNNEL;
|
|
|
|
} else {
|
|
|
|
return V_GET;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-08 16:41:21 +00:00
|
|
|
const SharedHandle<Option>& AbstractCommand::getOption() const
|
|
|
|
{
|
|
|
|
return _requestGroup->getOption();
|
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|