diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-01-25 10:55:27 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-01-25 10:55:27 +0000 |
| commit | 5def96906fd17d9b48e9fda192617c6ad1b95683 (patch) | |
| tree | 7907dd734fbaa2a43636c2a7fea342bb5ef773e5 /src/HttpServerCommand.cc | |
| parent | 0742e3921f185613f98c2b31cd03182d8aa1d6f5 (diff) | |
2009-01-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
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
Diffstat (limited to 'src/HttpServerCommand.cc')
| -rw-r--r-- | src/HttpServerCommand.cc | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/HttpServerCommand.cc b/src/HttpServerCommand.cc index 3670605b..4bbd0117 100644 --- a/src/HttpServerCommand.cc +++ b/src/HttpServerCommand.cc @@ -51,6 +51,7 @@ #include "HttpServerResponseCommand.h" #include "CheckIntegrityEntry.h" #include "FileAllocationEntry.h" +#include "RecoverableException.h" namespace aria2 { @@ -64,6 +65,18 @@ HttpServerCommand::HttpServerCommand(int32_t cuid, DownloadEngine* e, _e->addSocketForReadCheck(_socket, this); } +HttpServerCommand::HttpServerCommand(int32_t cuid, + const SharedHandle<HttpServer>& httpServer, + DownloadEngine* e, + const SharedHandle<SocketCore>& socket): + Command(cuid), + _e(e), + _socket(socket), + _httpServer(httpServer) +{ + _e->addSocketForReadCheck(_socket, this); +} + HttpServerCommand::~HttpServerCommand() { _e->deleteSocketForReadCheck(_socket, this); @@ -218,9 +231,19 @@ static std::string createResponse(DownloadEngine* e) bool HttpServerCommand::execute() { + if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) { + return true; + } if(_socket->isReadable(0)) { _timeout.reset(); - SharedHandle<HttpHeader> header = _httpServer->receiveRequest(); + SharedHandle<HttpHeader> header; + try { + header = _httpServer->receiveRequest(); + } catch(RecoverableException& e) { + logger->info("CUID#%d - Error occurred while reading HTTP request", + e, cuid); + return true; + } if(header.isNull()) { _e->commands.push_back(this); return false; |
