Flush out auth entries for 401 auth denied responses. And some filter work...

This commit is contained in:
gagan%netscape.com 2000-05-05 09:46:24 +00:00
Родитель 13e7b2f428
Коммит 12143c560d
3 изменённых файлов: 34 добавлений и 11 удалений

Просмотреть файл

@ -0,0 +1 @@
Makefile

Просмотреть файл

@ -1545,9 +1545,10 @@ nsresult nsHTTPChannel::ResponseCompleted(
{
nsresult rv = NS_OK;
PR_LOG(gHTTPLog, PR_LOG_ERROR, ("nsHTTPChannel::ResponseComplete() [this=%x] "
" mDataListenet=%x, Status=%o\n",
this, mResponseDataListener, aStatus));
PR_LOG(gHTTPLog, PR_LOG_ERROR,
("nsHTTPChannel::ResponseComplete() [this=%x] "
" mDataListenet=%x, Status=%o\n",
this, (void*)mResponseDataListener, aStatus));
#if 0
if (NS_FAILED (aStatus) && !mResponse)
@ -1712,6 +1713,15 @@ nsHTTPChannel::Authenticate(const char *iChallenge, PRBool iProxyAuth)
nsIChannel* channel;
if (!iChallenge)
return NS_ERROR_NULL_POINTER;
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
//flush out existing records of this URI in authengine-
nsAuthEngine* pEngine;
if (NS_SUCCEEDED(mHandler->GetAuthEngine(&pEngine)))
{
rv = pEngine->SetAuthString(mURI, 0);
}
// Determine the new username password combination to use
char* newUserPass = nsnull;
@ -1722,8 +1732,6 @@ nsHTTPChannel::Authenticate(const char *iChallenge, PRBool iProxyAuth)
if (NS_SUCCEEDED(rv = mURI->GetPreHost(getter_Copies(prehost))))
{
if ((const char*)prehost) {
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = serv->Unescape(prehost, &newUserPass);
if (NS_FAILED(rv)) return rv;
}
@ -1783,9 +1791,6 @@ nsHTTPChannel::Authenticate(const char *iChallenge, PRBool iProxyAuth)
return rv; // Failed to construct an authentication string.
// Construct a new channel
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
// For security/privacy purposes, a response to an authenticated request is
// not cached, except perhaps in the memory cache.
mLoadAttributes |= nsIChannel::INHIBIT_PERSISTENT_CACHING;
@ -1892,10 +1897,10 @@ nsHTTPChannel::ProcessStatusCode(void)
mProxy, mProxyPort, authString);
}
if (statusCode != 401 && mAuthTriedWithPrehost)
if ((statusCode != 401) && mAuthTriedWithPrehost)
{
rv = GetRequestHeader(nsHTTPAtoms::Authorization,
getter_Copies(authString));
getter_Copies(authString));
pEngine->SetAuthString(mURI, authString);
}
}
@ -2113,7 +2118,7 @@ nsHTTPChannel::ProcessAuthentication(PRInt32 aStatusCode)
nsresult rv = NS_OK; // Let life go on...
nsXPIDLCString challenge; // identifies the auth type and realm.
if (401 == aStatusCode)
{
rv = GetResponseHeader(nsHTTPAtoms::WWW_Authenticate,
@ -2126,6 +2131,7 @@ nsHTTPChannel::ProcessAuthentication(PRInt32 aStatusCode)
}
else
return rv;
// We can't send user-password without this challenge.
if (NS_FAILED(rv) || !challenge || !*challenge)
return rv;

Просмотреть файл

@ -49,6 +49,9 @@
#include "nsISupportsPrimitives.h"
#include "nsHTTPRequest.h"
#ifdef DEBUG_gagan
#include "nsIWebFilters.h"
#endif
#ifdef XP_UNIX
#include <sys/utsname.h>
@ -227,6 +230,19 @@ nsHTTPHandler::NewChannel(nsIURI* i_URL, nsIChannel **o_Instance)
if (scheme != nsnull && handlerScheme != nsnull &&
0 == PL_strcasecmp(scheme, handlerScheme))
{
#ifdef DEBUG_gagan
// Check for filtering
nsCOMPtr<nsIWebFilters> filters =
do_CreateInstance(NS_WEBFILTERS_PROGID, &rv);
if (NS_SUCCEEDED(rv))
{
PRBool allowLoading = PR_TRUE;
if (NS_SUCCEEDED(filters->AllowLoading(i_URL, &allowLoading)) &&
!allowLoading)
return NS_ERROR_FAILURE; // NS_ERROR_FILTERED
}
#endif
nsCOMPtr<nsIURI> channelURI;
PRUint32 count;
PRInt32 index;