Fix for bug # 135289. META http-equiv="cache-control" directives are ignored by back forward buttons. r=rpotts sr=darin.

This commit is contained in:
radha%netscape.com 2002-05-09 20:32:35 +00:00
parent ba98c296d5
commit a89a95f087
2 changed files with 35 additions and 9 deletions

View File

@ -3957,6 +3957,22 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
mEODForCurrentDocument = PR_TRUE;
}
/* Check if the httpChannel has any cache-control related response headers,
* like no-store, no-cache. If so, update SHEntry so that
* when a user goes back/forward to this page, we appropriately do
* form value restoration or load from server.
*/
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel));
if (!httpChannel) // HttpChannel could be hiding underneath a Multipart channel.
GetHttpChannel(aChannel, getter_AddRefs(httpChannel));
if (httpChannel) {
// figure out if SH should be saving layout state.
PRBool discardLayoutState = ShouldDiscardLayoutState(httpChannel);
if (mLSHE && discardLayoutState && (mLoadType & LOAD_CMD_NORMAL) && (mLoadType != LOAD_BYPASS_HISTORY))
mLSHE->SetSaveLayoutStateFlag(PR_FALSE);
}
// Clear mLSHE after calling the onLoadHandlers. This way, if the
// onLoadHandler tries to load something different in
// itself or one of its children, we can deal with it appropriately.
@ -5601,15 +5617,7 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI,
httpChannel->GetUploadStream(getter_AddRefs(inputStream));
httpChannel->GetReferrer(getter_AddRefs(referrerURI));
// figure out if SH should be saving layout state (see bug 112564)
nsCOMPtr<nsISupports> securityInfo;
PRBool noStore = PR_FALSE, noCache = PR_FALSE;
httpChannel->GetSecurityInfo(getter_AddRefs(securityInfo));
httpChannel->IsNoStoreResponse(&noStore);
httpChannel->IsNoCacheResponse(&noCache);
discardLayoutState = noStore || (noCache && securityInfo);
discardLayoutState = ShouldDiscardLayoutState(httpChannel);
}
}
@ -5876,6 +5884,23 @@ nsDocShell::GetHttpChannel(nsIChannel * aChannel, nsIHttpChannel ** aReturn)
return NS_OK;
}
PRBool
nsDocShell::ShouldDiscardLayoutState(nsIHttpChannel * aChannel)
{
// By default layout State will be saved.
if (!aChannel)
return PR_FALSE;
// figure out if SH should be saving layout state
nsCOMPtr<nsISupports> securityInfo;
PRBool noStore = PR_FALSE, noCache = PR_FALSE;
aChannel->GetSecurityInfo(getter_AddRefs(securityInfo));
aChannel->IsNoStoreResponse(&noStore);
aChannel->IsNoCacheResponse(&noCache);
return (noStore || (noCache && securityInfo));
}
//*****************************************************************************
// nsDocShell: Global History
//*****************************************************************************

View File

@ -233,6 +233,7 @@ protected:
nsISHEntry * areplaceEntry, nsISHEntry ** destEntry);
nsresult GetRootSessionHistory(nsISHistory ** aReturn);
nsresult GetHttpChannel(nsIChannel * aChannel, nsIHttpChannel ** aReturn);
PRBool ShouldDiscardLayoutState(nsIHttpChannel * aChannel);
// Global History
NS_IMETHOD ShouldAddToGlobalHistory(nsIURI * aURI, PRBool * aShouldAdd);