summaryrefslogtreecommitdiff
path: root/src/HttpRequestCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-04-01 23:51:33 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-04-01 23:51:33 +0900
commit26972b85359a4ab1f00545c9082a6c1b7d5a2593 (patch)
tree37c4d9c264e6281424137af235d0cef74b448bdb /src/HttpRequestCommand.cc
parentcf23e3e11dfc7abfd4b95c5ce200404113cbe8e8 (diff)
Rewrite backup connection handling
Now dedicated ConnectCommand handles connection establishment. It checks whether connection is established or not. It also handles backup connection. The next Command creation is abstracted using ControlChain struct template.
Diffstat (limited to 'src/HttpRequestCommand.cc')
-rw-r--r--src/HttpRequestCommand.cc57
1 files changed, 1 insertions, 56 deletions
diff --git a/src/HttpRequestCommand.cc b/src/HttpRequestCommand.cc
index 6fc083c6..971a861d 100644
--- a/src/HttpRequestCommand.cc
+++ b/src/HttpRequestCommand.cc
@@ -59,7 +59,6 @@
#include "LogFactory.h"
#include "fmt.h"
#include "SocketRecvBuffer.h"
-#include "BackupIPv4ConnectCommand.h"
namespace aria2 {
@@ -80,12 +79,7 @@ HttpRequestCommand::HttpRequestCommand
setWriteCheckSocket(getSocket());
}
-HttpRequestCommand::~HttpRequestCommand()
-{
- if(backupConnectionInfo_) {
- backupConnectionInfo_->cancel = true;
- }
-}
+HttpRequestCommand::~HttpRequestCommand() {}
namespace {
SharedHandle<HttpRequest>
@@ -128,52 +122,9 @@ createHttpRequest(const SharedHandle<Request>& req,
}
} // namespace
-bool HttpRequestCommand::noCheck() {
- return backupConnectionInfo_ && !backupConnectionInfo_->ipaddr.empty();
-}
-
bool HttpRequestCommand::executeInternal() {
//socket->setBlockingMode();
if(httpConnection_->sendBufferIsEmpty()) {
- if(backupConnectionInfo_ && !backupConnectionInfo_->ipaddr.empty()) {
- A2_LOG_INFO(fmt("CUID#%"PRId64" - Use backup connection address %s",
- getCuid(), backupConnectionInfo_->ipaddr.c_str()));
- getDownloadEngine()->markBadIPAddress
- (getRequest()->getConnectedHostname(),
- getRequest()->getConnectedAddr(),
- getRequest()->getConnectedPort());
-
- getRequest()->setConnectedAddrInfo(getRequest()->getConnectedHostname(),
- backupConnectionInfo_->ipaddr,
- getRequest()->getConnectedPort());
-
- SharedHandle<SocketRecvBuffer> socketRecvBuffer
- (new SocketRecvBuffer(backupConnectionInfo_->socket));
- SharedHandle<HttpConnection> httpConnection
- (new HttpConnection(getCuid(), backupConnectionInfo_->socket,
- socketRecvBuffer));
- HttpRequestCommand* c =
- new HttpRequestCommand(getCuid(), getRequest(), getFileEntry(),
- getRequestGroup(),
- httpConnection,
- getDownloadEngine(),
- backupConnectionInfo_->socket);
- c->setProxyRequest(proxyRequest_);
- c->setStatus(STATUS_ONESHOT_REALTIME);
- getDownloadEngine()->setNoWait(true);
- getDownloadEngine()->addCommand(c);
- backupConnectionInfo_.reset();
- return true;
- }
- if(!checkIfConnectionEstablished
- (getSocket(), getRequest()->getConnectedHostname(),
- getRequest()->getConnectedAddr(), getRequest()->getConnectedPort())) {
- return true;
- }
- if(backupConnectionInfo_) {
- backupConnectionInfo_->cancel = true;
- backupConnectionInfo_.reset();
- }
#ifdef ENABLE_SSL
if(getRequest()->getProtocol() == "https") {
if(!getSocket()->tlsConnect(getRequest()->getHost())) {
@@ -279,10 +230,4 @@ void HttpRequestCommand::setProxyRequest
proxyRequest_ = proxyRequest;
}
-void HttpRequestCommand::setBackupConnectInfo
-(const SharedHandle<BackupConnectInfo>& info)
-{
- backupConnectionInfo_ = info;
-}
-
} // namespace aria2