mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
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:
parent
0d9a295fc2
commit
c739c5639b
@ -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__
|
||||
|
Loading…
Reference in New Issue
Block a user