diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index bf2230a3c743..047b64528d96 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -107,6 +107,7 @@ nsHttpChannel::nsHttpChannel() , mFallingBack(PR_FALSE) , mWaitingForRedirectCallback(PR_FALSE) , mRemoteChannel(PR_FALSE) + , mRequestTimeInitialized(PR_FALSE) { LOG(("Creating nsHttpChannel [this=%p]\n", this)); } @@ -520,6 +521,7 @@ nsHttpChannel::SetupTransaction() // set the request time for cache expiration calculations mRequestTime = NowInSeconds(); + mRequestTimeInitialized = PR_TRUE; // if doing a reload, force end-to-end if (mLoadFlags & LOAD_BYPASS_CACHE) { @@ -3708,8 +3710,10 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st mStatus = status; // perform any final cache operations before we close the cache entry. - if (mCacheEntry && (mCacheAccess & nsICache::ACCESS_WRITE)) + if (mCacheEntry && (mCacheAccess & nsICache::ACCESS_WRITE) && + mRequestTimeInitialized){ FinalizeCacheEntry(); + } if (mListener) { LOG((" calling OnStopRequest\n")); diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h index fa69d6562831..e461ed0d6bf9 100644 --- a/netwerk/protocol/http/nsHttpChannel.h +++ b/netwerk/protocol/http/nsHttpChannel.h @@ -326,6 +326,9 @@ private: PRUint32 mWaitingForRedirectCallback : 1; // True iff this channel is servicing a remote HttpChannelChild PRUint32 mRemoteChannel : 1; + // True if mRequestTime has been set. In such a case it is safe to update + // the cache entry's expiration time. Otherwise, it is not(see bug 567360). + PRUint32 mRequestTimeInitialized : 1; class nsContentEncodings : public nsIUTF8StringEnumerator {