summaryrefslogtreecommitdiff
path: root/src/HttpRequest.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-09-25 14:37:28 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-09-25 14:37:28 +0000
commit92d702fa5349c722c6b59256bafe552c8b5cd8a1 (patch)
tree43dd76d729ceaf937351f15a428680f3a290f5a5 /src/HttpRequest.cc
parent6bc233f414b74bf3acf4abf5d5655c236e78ae41 (diff)
2008-09-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use netrc for HTTP. Now FTP user/password is sent in Authorization header when --ftp-via-http-proxy=get is given. * src/AuthConfigFactory.cc * src/HttpRequest.cc * src/HttpRequest.h * src/NetrcAuthResolver.cc * src/NetrcAuthResolver.h * src/OptionHandlerFactory.cc * src/option_processing.cc * src/prefs.cc * src/prefs.h * test/AuthConfigFactoryTest.cc * test/HttpRequestTest.cc * test/NetrcAuthResolverTest.cc
Diffstat (limited to 'src/HttpRequest.cc')
-rw-r--r--src/HttpRequest.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc
index 08235683..82d9c443 100644
--- a/src/HttpRequest.cc
+++ b/src/HttpRequest.cc
@@ -52,7 +52,6 @@ namespace aria2 {
const std::string HttpRequest::USER_AGENT("aria2");
HttpRequest::HttpRequest():entityLength(0),
- authEnabled(false),
proxyEnabled(false),
proxyAuthEnabled(false),
_contentEncodingEnabled(true),
@@ -193,9 +192,11 @@ std::string HttpRequest::createRequest() const
if(proxyEnabled && proxyAuthEnabled) {
requestLine += getProxyAuthString();
}
- if(authEnabled) {
+ std::string authString = AuthConfigFactorySingleton::instance()
+ ->createAuthConfig(request)->getAuthText();
+ if(authString != ":") {
requestLine += "Authorization: Basic "+
- Base64::encode(AuthConfigFactorySingleton::instance()->createAuthConfig(request)->getAuthText())+"\r\n";
+ Base64::encode(authString)+"\r\n";
}
if(getPreviousURI().size()) {
requestLine += "Referer: "+getPreviousURI()+"\r\n";
@@ -274,7 +275,6 @@ void HttpRequest::addAcceptType(const std::string& type)
void HttpRequest::configure(const Option* option)
{
- authEnabled = option->getAsBool(PREF_HTTP_AUTH_ENABLED);
proxyEnabled =
option->getAsBool(PREF_HTTP_PROXY_ENABLED) &&
option->get(PREF_HTTP_PROXY_METHOD) == V_GET;