summaryrefslogtreecommitdiff
path: root/src/HttpSkipResponseCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-01-30 16:12:41 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-01-30 16:12:41 +0000
commite5c4b24454a37ad6eb5eae3a0685115e4078a06a (patch)
tree16138c045553f9c1df8d71a14a62101640b0bf32 /src/HttpSkipResponseCommand.cc
parent120ea4c609b28c7fd3d907f1fa689737df92b8ef (diff)
2009-01-31 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Send HTTP Authorization header only if it is requested by the server(response 401). There are some exceptions. The authorization header for proxy is always sent if it is available without request by the server. If username/password is specified in the URI, it is immediately sent to the server without request by the server. AbstractAuthResolver::_defaultAuthConfig is now initialized as SharedHandle<AuthConfig>(). NetrcAuthResolver::resolveAuthConfig() returns SharedHandle<AuthConfig>() if no AuthConfig is available. * src/AbstractAuthResolver.cc * src/AbstractProxyRequestCommand.cc * src/AuthConfigFactory.cc * src/AuthConfigFactory.h * src/HttpConnection.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpResponse.cc * src/HttpResponseCommand.cc * src/HttpSkipResponseCommand.cc * test/AuthConfigFactoryTest.cc * test/HttpRequestTest.cc * test/HttpResponseTest.cc
Diffstat (limited to 'src/HttpSkipResponseCommand.cc')
-rw-r--r--src/HttpSkipResponseCommand.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/HttpSkipResponseCommand.cc b/src/HttpSkipResponseCommand.cc
index 358217c9..83a5775d 100644
--- a/src/HttpSkipResponseCommand.cc
+++ b/src/HttpSkipResponseCommand.cc
@@ -52,6 +52,7 @@
#include "Option.h"
#include "CookieStorage.h"
#include "AuthConfigFactory.h"
+#include "AuthConfig.h"
namespace aria2 {
@@ -158,7 +159,13 @@ bool HttpSkipResponseCommand::processResponse()
return prepareForRetry(_httpResponse->getRetryAfter());
} else if(_httpResponse->getResponseStatus() >= HttpHeader::S400) {
if(_httpResponse->getResponseStatus() == HttpHeader::S401) {
- throw DlAbortEx(EX_AUTH_FAILED);
+ if(!_httpResponse->getHttpRequest()->authenticationUsed() &&
+ e->getAuthConfigFactory()->activateBasicCred
+ (req->getHost(), req->getDir())) {
+ return prepareForRetry(0);
+ } else {
+ throw DlAbortEx(EX_AUTH_FAILED);
+ }
}else if(_httpResponse->getResponseStatus() == HttpHeader::S404) {
throw DlAbortEx(MSG_RESOURCE_NOT_FOUND,
DownloadResult::RESOURCE_NOT_FOUND);