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/HttpDownloadCommand.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/HttpDownloadCommand.cc') diff --git a/src/HttpDownloadCommand.cc b/src/HttpDownloadCommand.cc index 104d0ae1..13fcfffc 100644 --- a/src/HttpDownloadCommand.cc +++ b/src/HttpDownloadCommand.cc @@ -41,6 +41,8 @@ #include "HttpRequest.h" #include "Segment.h" #include "Socket.h" +#include "prefs.h" +#include "Option.h" namespace aria2 { @@ -61,6 +63,17 @@ bool HttpDownloadCommand::prepareForNextSegment() { e->commands.push_back(command); return true; } else { + if(!e->option->getAsBool(PREF_HTTP_PROXY_ENABLED)) { + if(req->isPipeliningEnabled() || + (req->isKeepAliveEnabled() && + ((!transferDecoder.isNull() && _requestGroup->downloadFinished()) || + (uint64_t)_segments.front()->getPositionToWrite() == _requestGroup->getTotalLength()))) { + std::pair peerInfo; + socket->getPeerInfo(peerInfo); + e->poolSocket(peerInfo.first, peerInfo.second, socket); + } + } + return DownloadCommand::prepareForNextSegment(); } } -- cgit