From c8d7edf2a2fbfa2c7e27ac657816ff81d71f628c Mon Sep 17 00:00:00 2001 From: "badami%netscape.com" Date: Wed, 20 Mar 2002 04:33:51 +0000 Subject: [PATCH] Redirection limit for this URL exceeded; Doom cache entry if redirecting back to self bug 127348 r=gagan sr=darin a=asa git-svn-id: svn://10.0.0.236/trunk@116947 18797224-902f-48f8-a5cc-f745e15eee43 --- .../netwerk/protocol/http/src/nsHttpChannel.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp index e33e0129698..ae25c288c4a 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp @@ -498,10 +498,14 @@ nsHttpChannel::ProcessResponse() case 302: case 307: // these redirects can be cached (don't store the response body) - if (mCacheEntry) - CloseCacheEntry(InitCacheEntry()); + if (mCacheEntry) { + rv = InitCacheEntry(); + if (NS_FAILED(rv)) + CloseCacheEntry(rv); + } rv = ProcessRedirection(httpStatus); + CloseCacheEntry(rv); if (NS_FAILED(rv)) { LOG(("ProcessRedirection failed [rv=%x]\n", rv)); rv = ProcessNormal(); @@ -1240,6 +1244,14 @@ nsHttpChannel::ProcessRedirection(PRUint32 redirectType) getter_AddRefs(newURI)); if (NS_FAILED(rv)) return rv; + // Kill the current cache entry if we are redirecting + // back to ourself. + PRBool redirectingBackToSameURI = PR_FALSE; + if (mCacheEntry && (mCacheAccess & nsICache::ACCESS_WRITE) && + NS_SUCCEEDED(mURI->Equals(newURI, &redirectingBackToSameURI)) && + redirectingBackToSameURI) + mCacheEntry->Doom(); + // move the reference of the old location to the new one if the new // one has none. nsCOMPtr newURL = do_QueryInterface(newURI, &rv);