summaryrefslogtreecommitdiff
path: root/src/HttpInitiateConnectionCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-04-22 08:52:47 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-04-22 08:52:47 +0000
commit5f55bc197ff9aa8b8bbcd030f2c32995661aac07 (patch)
tree5cf208048aa83658798fd7658ac67c1ec7551d60 /src/HttpInitiateConnectionCommand.cc
parent1c7c6f989800b10d3820614123dcfc7d90677c85 (diff)
2008-04-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Reuse socket if the origin server supports HTTP keep-alive and --enable-http-keep-alive or --enable-http-pipelining is given. The current implementation doesn't reuse the connections established against proxy server. * src/AbstractCommand.cc * src/DownloadEngine.cc * src/DownloadEngine.h * src/HttpDownloadCommand.cc * src/HttpInitiateConnectionCommand.cc * src/HttpResponseCommand.cc
Diffstat (limited to 'src/HttpInitiateConnectionCommand.cc')
-rw-r--r--src/HttpInitiateConnectionCommand.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/HttpInitiateConnectionCommand.cc b/src/HttpInitiateConnectionCommand.cc
index f0e6c6d2..6e904116 100644
--- a/src/HttpInitiateConnectionCommand.cc
+++ b/src/HttpInitiateConnectionCommand.cc
@@ -103,9 +103,16 @@ bool HttpInitiateConnectionCommand::executeInternal() {
throw new DlAbortEx("ERROR");
}
} else {
- logger->info(MSG_CONNECTING_TO_SERVER, cuid, req->getHost().c_str(),
- req->getPort());
- socket->establishConnection(hostname, req->getPort());
+ SharedHandle<SocketCore> pooledSocket =
+ e->popPooledSocket(hostname, req->getPort());
+
+ if(pooledSocket.isNull()) {
+ logger->info(MSG_CONNECTING_TO_SERVER, cuid, req->getHost().c_str(),
+ req->getPort());
+ socket->establishConnection(hostname, req->getPort());
+ } else {
+ socket = pooledSocket;
+ }
SharedHandle<HttpConnection> httpConnection(new HttpConnection(cuid, socket, e->option));
command = new HttpRequestCommand(cuid, req, _requestGroup, httpConnection,
e, socket);