From 80045583a292e6b80823d540cb1e97c27cf1381b Mon Sep 17 00:00:00 2001 From: Honza Bambas Date: Tue, 23 Oct 2012 17:37:02 +0200 Subject: [PATCH] Backout of changeset 6f1121e69ee9 --- content/base/test/file_XHR_anon.sjs | 3 +- content/base/test/test_XHR_anon.html | 207 +++++------------- .../http/nsHttpChannelAuthProvider.cpp | 32 ++- 3 files changed, 72 insertions(+), 170 deletions(-) diff --git a/content/base/test/file_XHR_anon.sjs b/content/base/test/file_XHR_anon.sjs index c6f400ec9bf..cd23ebbf8c6 100644 --- a/content/base/test/file_XHR_anon.sjs +++ b/content/base/test/file_XHR_anon.sjs @@ -6,8 +6,7 @@ function handleRequest(request, response) { if (request.hasHeader("Authorization")) { headers["authorization"] = request.getHeader("Authorization"); } else { - response.setStatusLine(null, 401, "Authentication required"); - response.setHeader("WWW-Authenticate", "basic realm=\"testrealm\"", true); + response.setStatusLine(null, 500, "Server Error"); } } else { invalidHeaders.push("Authorization"); diff --git a/content/base/test/test_XHR_anon.html b/content/base/test/test_XHR_anon.html index e02af8619b4..fb612cec515 100644 --- a/content/base/test/test_XHR_anon.html +++ b/content/base/test/test_XHR_anon.html @@ -16,162 +16,71 @@
 
 
diff --git a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp index 728bef2c3e0..4a5afed3aea 100644 --- a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp +++ b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp @@ -92,9 +92,20 @@ nsHttpChannelAuthProvider::ProcessAuthentication(uint32_t httpStatus, if (!mProxyInfo) return NS_ERROR_NO_INTERFACE; } + uint32_t loadFlags; + rv = mAuthChannel->GetLoadFlags(&loadFlags); + if (NS_FAILED(rv)) return rv; + nsAutoCString challenges; mProxyAuth = (httpStatus == 407); + // Do proxy auth even if we're LOAD_ANONYMOUS + if ((loadFlags & nsIRequest::LOAD_ANONYMOUS) && + (!mProxyAuth || !UsingHttpProxy())) { + LOG(("Skipping authentication for anonymous non-proxy request\n")); + return NS_ERROR_NOT_AVAILABLE; + } + rv = PrepareForAuthentication(mProxyAuth); if (NS_FAILED(rv)) return rv; @@ -665,10 +676,6 @@ nsHttpChannelAuthProvider::GetCredentialsForChallenge(const char *challenge, path, ident, continuationState); if (NS_FAILED(rv)) return rv; - uint32_t loadFlags; - rv = mAuthChannel->GetLoadFlags(&loadFlags); - if (NS_FAILED(rv)) return rv; - if (!proxyAuth) { // if this is the first challenge, then try using the identity // specified in the URL. @@ -676,18 +683,6 @@ nsHttpChannelAuthProvider::GetCredentialsForChallenge(const char *challenge, GetIdentityFromURI(authFlags, mIdent); identFromURI = !mIdent.IsEmpty(); } - - if ((loadFlags & nsIRequest::LOAD_ANONYMOUS) && !identFromURI) { - LOG(("Skipping authentication for anonymous non-proxy request\n")); - return NS_ERROR_NOT_AVAILABLE; - } - - // Let explicit URL credentials pass - // regardless of the LOAD_ANONYMOUS flag - } - else if ((loadFlags & nsIRequest::LOAD_ANONYMOUS) && !UsingHttpProxy()) { - LOG(("Skipping authentication for anonymous non-proxy request\n")); - return NS_ERROR_NOT_AVAILABLE; } // @@ -734,9 +729,8 @@ nsHttpChannelAuthProvider::GetCredentialsForChallenge(const char *challenge, } } else if (!identFromURI || - (nsCRT::strcmp(ident->User(), - entry->Identity().User()) == 0 && - !(loadFlags && nsIChannel::LOAD_ANONYMOUS))) { + nsCRT::strcmp(ident->User(), + entry->Identity().User()) == 0) { LOG((" taking identity from auth cache\n")); // the password from the auth cache is more likely to be // correct than the one in the URL. at least, we know that it