diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-04-01 00:12:27 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-04-01 00:12:27 +0900 |
| commit | 597e1a5c1b10aa3668f91bcae02a864dcd0c045b (patch) | |
| tree | 4437c2896b410b441013452b7385dfa303441772 /src/HttpInitiateConnectionCommand.cc | |
| parent | d671d8bf3672cbefc06f3727f82b77872abe6120 (diff) | |
Implement simple Happy Eyeballs for HTTP/FTP downloads
Diffstat (limited to 'src/HttpInitiateConnectionCommand.cc')
| -rw-r--r-- | src/HttpInitiateConnectionCommand.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/HttpInitiateConnectionCommand.cc b/src/HttpInitiateConnectionCommand.cc index 794b1886..deb9c62d 100644 --- a/src/HttpInitiateConnectionCommand.cc +++ b/src/HttpInitiateConnectionCommand.cc @@ -51,6 +51,7 @@ #include "util.h" #include "fmt.h" #include "SocketRecvBuffer.h" +#include "BackupIPv4ConnectCommand.h" namespace aria2 { @@ -93,6 +94,11 @@ Command* HttpInitiateConnectionCommand::createNextCommand getDownloadEngine(), proxyRequest, getSocket()); + SharedHandle<BackupConnectInfo> backupConnectionInfo + = createBackupIPv4ConnectCommand(hostname, addr, port, c); + if(backupConnectionInfo) { + c->setBackupConnectInfo(backupConnectionInfo); + } command = c; } else if(proxyMethod == V_GET) { SharedHandle<SocketRecvBuffer> socketRecvBuffer @@ -107,6 +113,11 @@ Command* HttpInitiateConnectionCommand::createNextCommand getDownloadEngine(), getSocket()); c->setProxyRequest(proxyRequest); + SharedHandle<BackupConnectInfo> backupConnectionInfo + = createBackupIPv4ConnectCommand(hostname, addr, port, c); + if(backupConnectionInfo) { + c->setBackupConnectInfo(backupConnectionInfo); + } command = c; } else { // TODO @@ -131,6 +142,7 @@ Command* HttpInitiateConnectionCommand::createNextCommand command = c; } } else { + bool connectRequired = false; SharedHandle<SocketCore> pooledSocket = getDownloadEngine()->popPooledSocket (resolvedAddresses, getRequest()->getPort()); @@ -141,6 +153,7 @@ Command* HttpInitiateConnectionCommand::createNextCommand getSocket()->establishConnection(addr, port); getRequest()->setConnectedAddrInfo(hostname, addr, port); + connectRequired = true; } else { setSocket(pooledSocket); setConnectedAddrInfo(getRequest(), hostname, pooledSocket); @@ -155,6 +168,14 @@ Command* HttpInitiateConnectionCommand::createNextCommand httpConnection, getDownloadEngine(), getSocket()); + if(connectRequired) { + SharedHandle<BackupConnectInfo> backupConnectInfo + = createBackupIPv4ConnectCommand(hostname, addr, port, c); + if(backupConnectInfo) { + c->setBackupConnectInfo(backupConnectInfo); + } + } + command = c; } return command; |
