From 0e428e3c6f14a011a93a1a8944d4704fd86d5875 Mon Sep 17 00:00:00 2001 From: "darin%meer.net" Date: Fri, 22 Jul 2005 07:54:09 +0000 Subject: [PATCH] fixes bug 300010 "Canceling a HTTP request while it is reading a partial cache entry does not cancel the corresponding transaction" r=biesi sr=bz a=bsmedberg --- netwerk/protocol/http/src/nsHttpChannel.cpp | 29 ++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/netwerk/protocol/http/src/nsHttpChannel.cpp b/netwerk/protocol/http/src/nsHttpChannel.cpp index 0bccf5ba90b1..8b4a8cbe0bcb 100644 --- a/netwerk/protocol/http/src/nsHttpChannel.cpp +++ b/netwerk/protocol/http/src/nsHttpChannel.cpp @@ -3912,20 +3912,25 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st if (mCanceled || NS_FAILED(mStatus)) status = mStatus; - if (mCachedContentIsPartial && NS_SUCCEEDED(status)) { - // mTransactionPump should be suspended - NS_ASSERTION(request != mTransactionPump, - "byte-range transaction finished prematurely"); + if (mCachedContentIsPartial) { + if (NS_SUCCEEDED(status)) { + // mTransactionPump should be suspended + NS_ASSERTION(request != mTransactionPump, + "byte-range transaction finished prematurely"); - if (request == mCachePump) { - PRBool streamDone; - status = OnDoneReadingPartialCacheEntry(&streamDone); - if (NS_SUCCEEDED(status) && !streamDone) - return status; - // otherwise, fall through and fire OnStopRequest... + if (request == mCachePump) { + PRBool streamDone; + status = OnDoneReadingPartialCacheEntry(&streamDone); + if (NS_SUCCEEDED(status) && !streamDone) + return status; + // otherwise, fall through and fire OnStopRequest... + } + else + NS_NOTREACHED("unexpected request"); } - else - NS_NOTREACHED("unexpected request"); + // Do not to leave the transaction in a suspended state in error cases. + if (NS_FAILED(status) && mTransaction) + gHttpHandler->CancelTransaction(mTransaction, status); } PRBool isPartial = PR_FALSE;