diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-02-19 12:02:22 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-02-19 12:02:22 +0000 |
| commit | 120e2de09646b200a78e971d24b061a1d9e47b67 (patch) | |
| tree | ade6510fefb3c6a9f6e355110ccb219812facb80 /src/AuthConfigFactory.cc | |
| parent | deb0625edb39039b8857ce914e07557d22123555 (diff) | |
2009-02-19 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added --http-auth-challenge option. If it is set to true(by
default), aria2 sends HTTP authorization header only when it is
requested by the server. If false is set, then authorization
header is always sent to the server. This is useful for servers
that don't respond 401 code when authentication is required.
There is an exception: if username and password are embedded in
URI, authorization header is always sent to the server
regardless of this option.
* src/AuthConfigFactory.cc
* src/HttpSkipResponseCommand.cc
* src/OptionHandlerFactory.cc
* src/prefs.cc
* src/prefs.h
* src/usage_text.h
* test/AuthConfigFactoryTest.cc
* test/HttpRequestTest.cc
Diffstat (limited to 'src/AuthConfigFactory.cc')
| -rw-r--r-- | src/AuthConfigFactory.cc | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/AuthConfigFactory.cc b/src/AuthConfigFactory.cc index c5bf4f9f..054091bf 100644 --- a/src/AuthConfigFactory.cc +++ b/src/AuthConfigFactory.cc @@ -62,21 +62,27 @@ AuthConfigFactory::createAuthConfig(const RequestHandle& request) if(request->getProtocol() == Request::PROTO_HTTP || request->getProtocol() == Request::PROTO_HTTPS) { - if(!request->getUsername().empty()) { - // TODO setting "/" as path. Should we use request->getDir() instead? - updateBasicCred(BasicCred(request->getUsername(), request->getPassword(), - request->getHost(), "/", true)); - return createAuthConfig(request->getUsername(), request->getPassword()); - } - std::deque<BasicCred>::const_iterator i = - findBasicCred(request->getHost(), request->getDir()); - if(i == _basicCreds.end()) { - return SharedHandle<AuthConfig>(); + if(_option->getAsBool(PREF_HTTP_AUTH_CHALLENGE)) { + if(!request->getUsername().empty()) { + // TODO setting "/" as path. Should we use request->getDir() instead? + updateBasicCred(BasicCred(request->getUsername(), request->getPassword(), + request->getHost(), "/", true)); + return createAuthConfig(request->getUsername(), request->getPassword()); + } + std::deque<BasicCred>::const_iterator i = + findBasicCred(request->getHost(), request->getDir()); + if(i == _basicCreds.end()) { + return SharedHandle<AuthConfig>(); + } else { + return createAuthConfig((*i)._user, (*i)._password); + } } else { - return createAuthConfig((*i)._user, (*i)._password); + if(!request->getUsername().empty()) { + return createAuthConfig(request->getUsername(), request->getPassword()); + } else { + return createHttpAuthResolver()->resolveAuthConfig(request->getHost()); + } } - - return createHttpAuthResolver()->resolveAuthConfig(request->getHost()); } else if(request->getProtocol() == Request::PROTO_FTP) { if(!request->getUsername().empty()) { return createAuthConfig(request->getUsername(), request->getPassword()); |
