diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-05-09 15:38:23 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-05-09 15:38:23 +0000 |
| commit | 7aefbb7338b69ff75f21a7d96ce57a0b71c79836 (patch) | |
| tree | ab02b8680adab4088ffd8d0b63e0eaa92863846c /src/HttpServerCommand.cc | |
| parent | d237c5e442ea2c7963837bb94d90ff2940b34830 (diff) | |
2009-05-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added BASIC authentication for XML-RPC. Added --xml-rpc-user and
--xml-rpc-passwd option.
* src/HttpServer.cc
* src/HttpServer.h
* src/HttpServerCommand.cc
* src/OptionHandlerFactory.cc
* src/prefs.cc
* src/prefs.h
* src/usage_text.h
Diffstat (limited to 'src/HttpServerCommand.cc')
| -rw-r--r-- | src/HttpServerCommand.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/HttpServerCommand.cc b/src/HttpServerCommand.cc index 7d889945..725fe582 100644 --- a/src/HttpServerCommand.cc +++ b/src/HttpServerCommand.cc @@ -41,7 +41,10 @@ #include "RequestGroup.h" #include "RequestGroupMan.h" #include "HttpServerBodyCommand.h" +#include "HttpServerResponseCommand.h" #include "RecoverableException.h" +#include "prefs.h" +#include "Option.h" namespace aria2 { @@ -53,6 +56,8 @@ HttpServerCommand::HttpServerCommand(int32_t cuid, DownloadEngine* e, _httpServer(new HttpServer(socket, e)) { _e->addSocketForReadCheck(_socket, this); + _httpServer->setUsernamePassword(_e->option->get(PREF_XML_RPC_USER), + _e->option->get(PREF_XML_RPC_PASSWD)); } HttpServerCommand::HttpServerCommand(int32_t cuid, @@ -87,6 +92,18 @@ bool HttpServerCommand::execute() e, cuid); return true; } + if(!_httpServer->authenticate()) { + _httpServer->disableKeepAlive(); + _httpServer->feedResponse("401 Unauthorized", + "WWW-Authenticate: Basic realm=\"aria2\"", + "","text/html"); + Command* command = + new HttpServerResponseCommand(cuid, _httpServer, _e, _socket); + command->setStatus(Command::STATUS_ONESHOT_REALTIME); + _e->commands.push_back(command); + _e->setNoWait(true); + return true; + } if(header.isNull()) { _e->commands.push_back(this); return false; |
