From 5f55bc197ff9aa8b8bbcd030f2c32995661aac07 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 22 Apr 2008 08:52:47 +0000 Subject: 2008-04-22 Tatsuhiro Tsujikawa 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 --- src/HttpInitiateConnectionCommand.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/HttpInitiateConnectionCommand.cc') 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 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(new HttpConnection(cuid, socket, e->option)); command = new HttpRequestCommand(cuid, req, _requestGroup, httpConnection, e, socket); -- cgit