diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 806867a565ec..b50202239fd4 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -2216,8 +2216,7 @@ nsHttpChannel::MaybeSetupByteRangeRequest(int64_t partialLen, int64_t contentLen nsresult rv = SetupByteRangeRequest(partialLen); if (NS_FAILED(rv)) { // Make the request unconditional again. - mRequestHead.ClearHeader(nsHttp::Range); - mRequestHead.ClearHeader(nsHttp::If_Range); + UntieByteRangeRequest(); } return rv; @@ -2251,6 +2250,13 @@ nsHttpChannel::SetupByteRangeRequest(int64_t partialLen) return NS_OK; } +void +nsHttpChannel::UntieByteRangeRequest() +{ + mRequestHead.ClearHeader(nsHttp::Range); + mRequestHead.ClearHeader(nsHttp::If_Range); +} + nsresult nsHttpChannel::ProcessPartialContent() { @@ -2965,9 +2971,16 @@ nsHttpChannel::OnCacheEntryCheck(nsICacheEntry* entry, nsIApplicationCache* appC mCachedContentIsPartial = NS_SUCCEEDED(rv) && mIsPartialRequest; if (mCachedContentIsPartial) { rv = OpenCacheInputStream(entry, false, !!appCache); + if (NS_FAILED(rv)) { + UntieByteRangeRequest(); + return rv; + } + *aResult = ENTRY_NEEDS_REVALIDATION; - return rv; - } else if (size == 0 && mCacheOnlyMetadata) { + return NS_OK; + } + + if (size == 0 && mCacheOnlyMetadata) { // Don't break cache entry load when the entry's data size // is 0 and mCacheOnlyMetadata flag is set. In that case we // want to proceed since the LOAD_ONLY_IF_MODIFIED flag is diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h index 171c0e2210fe..0545a0c88dff 100644 --- a/netwerk/protocol/http/nsHttpChannel.h +++ b/netwerk/protocol/http/nsHttpChannel.h @@ -367,6 +367,7 @@ private: nsresult MaybeSetupByteRangeRequest(int64_t partialLen, int64_t contentLength, bool ignoreMissingPartialLen = false); nsresult SetupByteRangeRequest(int64_t partialLen); + void UntieByteRangeRequest(); nsresult OpenCacheInputStream(nsICacheEntry* cacheEntry, bool startBuffering, bool checkingAppCacheEntry);