fixes bug 114286 "No way to determine if a http request was a 304 or not."

r=pavlov, sr=mscott
This commit is contained in:
darin%netscape.com 2001-12-14 22:53:13 +00:00
Родитель 0d9a295fc2
Коммит c739c5639b
3 изменённых файлов: 25 добавлений и 2 удалений

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

@ -93,6 +93,13 @@ interface nsICachingChannel : nsISupports
* an error if cacheAsFile is false.
*/
readonly attribute nsIFile cacheFile;
/**
* TRUE if this channel's data is being loaded from the cache. This value
* is undefined before the channel fires its OnStartRequest notification
* and after the channel fires its OnStopRequest notification.
*/
boolean isFromCache();
};
%{C++

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

@ -68,6 +68,7 @@ nsHttpChannel::nsHttpChannel()
, mFromCacheOnly(PR_FALSE)
, mCachedContentIsValid(PR_FALSE)
, mResponseHeadersModified(PR_FALSE)
, mCanceled(PR_FALSE)
{
LOG(("Creating nsHttpChannel @%x\n", this));
@ -1751,6 +1752,7 @@ NS_IMETHODIMP
nsHttpChannel::Cancel(nsresult status)
{
LOG(("nsHttpChannel::Cancel [this=%x status=%x]\n", this, status));
mCanceled = PR_TRUE;
mStatus = status;
if (mTransaction)
mTransaction->Cancel(status);
@ -2387,8 +2389,14 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st
mListenerContext = 0;
}
if (mCacheEntry)
CloseCacheEntry(status);
if (mCacheEntry) {
// we don't want to discard the cache entry if canceled and
// reading from the cache.
if (mCanceled && (request == mCacheReadRequest))
CloseCacheEntry(NS_OK);
else
CloseCacheEntry(status);
}
if (mLoadGroup)
mLoadGroup->RemoveRequest(this, nsnull, status);
@ -2571,6 +2579,13 @@ nsHttpChannel::GetCacheFile(nsIFile **cacheFile)
return mCacheEntry->GetFile(cacheFile);
}
NS_IMETHODIMP
nsHttpChannel::IsFromCache(PRBool *value)
{
*value = (mCacheReadRequest != nsnull);
return NS_OK;
}
//-----------------------------------------------------------------------------
// nsHttpChannel::nsICacheListener
//-----------------------------------------------------------------------------

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

@ -171,6 +171,7 @@ private:
PRPackedBool mFromCacheOnly;
PRPackedBool mCachedContentIsValid;
PRPackedBool mResponseHeadersModified;
PRPackedBool mCanceled;
};
#endif // nsHttpChannel_h__