Bug 579846 - nsIHttpChannel::SetResponseHeader should work after the stream has ended, r=bzbarsky+hsivonen, a=betaN+

This commit is contained in:
Honza Bambas
2011-01-23 23:49:30 +01:00
parent 12b17b1e9a
commit 119a06dba5
9 changed files with 188 additions and 11 deletions

View File

@@ -41,6 +41,7 @@
#include "nsHtml5StreamParser.h"
#include "nsICharsetConverterManager.h"
#include "nsICharsetAlias.h"
#include "nsICacheInfoChannel.h"
#include "nsServiceManagerUtils.h"
#include "nsEncoderDecoderUtils.h"
#include "nsContentUtils.h"
@@ -220,6 +221,7 @@ nsHtml5StreamParser::~nsHtml5StreamParser()
mTokenizer->end();
NS_ASSERTION(!mFlushTimer, "Flush timer was not dropped before dtor!");
#ifdef DEBUG
mCacheEntryClosePreventer = nsnull;
mRequest = nsnull;
mObserver = nsnull;
mUnicodeDecoder = nsnull;
@@ -558,6 +560,17 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
}
mRequest = aRequest;
// We must keep the cache entry hold lock to prevent the channel from
// dropping the cache entry after OnStopRequest. We may need to modify
// the cache entry asynchronously, after OnStopRequest.
// See bug 579846.
nsCOMPtr<nsICacheInfoChannel_GECKO_2_0> cacheInfoChannel =
do_QueryInterface(aRequest);
if (cacheInfoChannel) {
cacheInfoChannel->
GetCacheEntryClosePreventer(getter_AddRefs(mCacheEntryClosePreventer));
}
mStreamState = STREAM_BEING_READ;
PRBool scriptingEnabled = mExecutor->IsScriptEnabled();