Bug 1321528: Part 1 - Support suspending requests when processing response headers. r?mayhemer
MozReview-Commit-ID: 8ZtbvqLDksO
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -1990,16 +1990,36 @@ nsHttpChannel::ProcessResponse()
MOZ_ASSERT(!mCachedContentIsValid);
ProcessSSLInformation();
// notify "http-on-examine-response" observers
gHttpHandler->OnExamineResponse(this);
+ return ContinueProcessResponse0();
+}
+
+void
+nsHttpChannel::AsyncContinueProcessResponse()
+{
+ Unused << NS_WARN_IF(NS_FAILED(ContinueProcessResponse0()));
+}
+
+nsresult
+nsHttpChannel::ContinueProcessResponse0()
+{
+ if (mSuspendCount) {
+ LOG(("Waiting until resume to finish processing response [this=%p]\n", this));
+ mCallOnResume = &nsHttpChannel::AsyncContinueProcessResponse;
+ return NS_OK;
+ }
+
+ uint32_t httpStatus = mResponseHead->Status();
+
// Cookies and Alt-Service should not be handled on proxy failure either.
// This would be consolidated with ProcessSecurityHeaders but it should
// happen after OnExamineResponse.
if (!mTransaction->ProxyConnectFailed() && (httpStatus != 407)) {
nsAutoCString cookie;
if (NS_SUCCEEDED(mResponseHead->GetHeader(nsHttp::Set_Cookie, cookie))) {
SetCookie(cookie.get());
}
@@ -2029,17 +2049,17 @@ nsHttpChannel::ProcessResponse()
}
if (mAPIRedirectToURI && !mCanceled) {
MOZ_ASSERT(!mOnStartRequestCalled);
nsCOMPtr<nsIURI> redirectTo;
mAPIRedirectToURI.swap(redirectTo);
PushRedirectAsyncFunc(&nsHttpChannel::ContinueProcessResponse1);
- rv = StartRedirectChannelToURI(redirectTo, nsIChannelEventSink::REDIRECT_TEMPORARY);
+ nsresult rv = StartRedirectChannelToURI(redirectTo, nsIChannelEventSink::REDIRECT_TEMPORARY);
if (NS_SUCCEEDED(rv)) {
return NS_OK;
}
PopRedirectAsyncFunc(&nsHttpChannel::ContinueProcessResponse1);
}
// Hack: ContinueProcessResponse1 uses NS_OK to detect successful
// redirects, so we distinguish this codepath (a non-redirect that's
--- a/netwerk/protocol/http/nsHttpChannel.h
+++ b/netwerk/protocol/http/nsHttpChannel.h
@@ -284,16 +284,18 @@ private:
nsresult ContinueBeginConnectWithResult();
void ContinueBeginConnect();
nsresult Connect();
void SpeculativeConnect();
nsresult SetupTransaction();
void SetupTransactionRequestContext();
nsresult CallOnStartRequest();
nsresult ProcessResponse();
+ void AsyncContinueProcessResponse();
+ nsresult ContinueProcessResponse0();
nsresult ContinueProcessResponse1(nsresult);
nsresult ContinueProcessResponse2(nsresult);
nsresult ProcessNormal();
nsresult ContinueProcessNormal(nsresult);
void ProcessAltService();
bool ShouldBypassProcessNotModified();
nsresult ProcessNotModified();
nsresult AsyncProcessRedirection(uint32_t httpStatus);