mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 22:05:40 +00:00
Fetch the Content-Length from the hash bag instead of directly from the channel. r=dwitte, a=betaN+
This commit is contained in:
parent
eb546c096c
commit
b169f8b65d
1
netwerk/cache/nsCacheEntry.cpp
vendored
1
netwerk/cache/nsCacheEntry.cpp
vendored
@ -62,6 +62,7 @@ nsCacheEntry::nsCacheEntry(nsCString * key,
|
|||||||
mLastModified(0),
|
mLastModified(0),
|
||||||
mExpirationTime(nsICache::NO_EXPIRATION_TIME),
|
mExpirationTime(nsICache::NO_EXPIRATION_TIME),
|
||||||
mFlags(0),
|
mFlags(0),
|
||||||
|
mPredictedDataSize(-1),
|
||||||
mDataSize(0),
|
mDataSize(0),
|
||||||
mCacheDevice(nsnull),
|
mCacheDevice(nsnull),
|
||||||
mData(nsnull)
|
mData(nsnull)
|
||||||
|
@ -755,10 +755,20 @@ nsHttpChannel::CallOnStartRequest()
|
|||||||
if (mResponseHead && mResponseHead->ContentCharset().IsEmpty())
|
if (mResponseHead && mResponseHead->ContentCharset().IsEmpty())
|
||||||
mResponseHead->SetContentCharset(mContentCharsetHint);
|
mResponseHead->SetContentCharset(mContentCharsetHint);
|
||||||
|
|
||||||
if (mResponseHead)
|
if (mResponseHead) {
|
||||||
SetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH,
|
SetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH,
|
||||||
mResponseHead->ContentLength());
|
mResponseHead->ContentLength());
|
||||||
|
// If we have a cache entry, set its predicted size to ContentLength to
|
||||||
|
// avoid caching an entry that will exceed the max size limit.
|
||||||
|
if (mCacheEntry) {
|
||||||
|
nsresult rv;
|
||||||
|
PRInt64 predictedDataSize = -1; // -1 in case GetAsInt64 fails.
|
||||||
|
GetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH,
|
||||||
|
&predictedDataSize);
|
||||||
|
rv = mCacheEntry->SetPredictedDataSize(predictedDataSize);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Allow consumers to override our content type
|
// Allow consumers to override our content type
|
||||||
if ((mLoadFlags & LOAD_CALL_CONTENT_SNIFFERS) &&
|
if ((mLoadFlags & LOAD_CALL_CONTENT_SNIFFERS) &&
|
||||||
gIOService->GetContentSniffers().Count() != 0) {
|
gIOService->GetContentSniffers().Count() != 0) {
|
||||||
@ -2798,13 +2808,6 @@ nsHttpChannel::InitCacheEntry()
|
|||||||
rv = AddCacheEntryHeaders(mCacheEntry);
|
rv = AddCacheEntryHeaders(mCacheEntry);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// set predicted size of entry so we do not store anything that will exceed
|
|
||||||
// the max entry size limit
|
|
||||||
PRInt64 predictedDataSize;
|
|
||||||
GetContentLength(&predictedDataSize);
|
|
||||||
rv = mCacheEntry->SetPredictedDataSize(predictedDataSize);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
mInitedCacheEntry = PR_TRUE;
|
mInitedCacheEntry = PR_TRUE;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user