From 5def96906fd17d9b48e9fda192617c6ad1b95683 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 25 Jan 2009 10:55:27 +0000 Subject: 2009-01-25 Tatsuhiro Tsujikawa Persist connection between the built-in HTTP server and a client if a client supports keep-alive. Fixed the bug that aria2 exits when the HTTP server receives EOF from a client. * src/HttpServer.cc * src/HttpServer.h * src/HttpServerCommand.cc * src/HttpServerCommand.h * src/HttpServerResponseCommand.cc --- src/HttpServerResponseCommand.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/HttpServerResponseCommand.cc') diff --git a/src/HttpServerResponseCommand.cc b/src/HttpServerResponseCommand.cc index 0578c7a8..ca096b93 100644 --- a/src/HttpServerResponseCommand.cc +++ b/src/HttpServerResponseCommand.cc @@ -37,6 +37,8 @@ #include "DownloadEngine.h" #include "HttpServer.h" #include "Logger.h" +#include "HttpServerCommand.h" +#include "RequestGroupMan.h" namespace aria2 { @@ -61,9 +63,17 @@ HttpServerResponseCommand::~HttpServerResponseCommand() bool HttpServerResponseCommand::execute() { + if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) { + return true; + } _httpServer->sendResponse(); if(_httpServer->sendBufferIsEmpty()) { logger->info("CUID#%d - HttpServer: all response transmitted.", cuid); + if(_httpServer->supportsPersistentConnection()) { + logger->info("CUID#%d - Persist connection.", cuid); + _e->commands.push_back + (new HttpServerCommand(cuid, _httpServer, _e, _socket)); + } return true; } else { if(_timeout.elapsed(10)) { -- cgit