From ce0d541c567adcd415e7d7b0a3ce9a5cf5c296e1 Mon Sep 17 00:00:00 2001 From: Dragana Damjanovic Date: Tue, 16 Sep 2014 06:30:00 -0400 Subject: [PATCH] Bug 1067346 - Fix "apply conversion" when channel is diverted to parent. r=jduell --- netwerk/protocol/http/HttpBaseChannel.cpp | 8 +++++--- netwerk/protocol/http/HttpChannelChild.cpp | 13 +++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index f636eee51ff..3c09c6f3039 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -611,9 +611,11 @@ HttpBaseChannel::DoApplyContentConversions(nsIStreamListener* aNextListener, nsISupports *aCtxt) { *aNewNextListener = nullptr; - nsCOMPtr nextListener = aNextListener; - if (!mResponseHead) + if (!mResponseHead || ! aNextListener) { return NS_OK; + } + + nsCOMPtr nextListener = aNextListener; LOG(("HttpBaseChannel::DoApplyContentConversions [this=%p]\n", this)); @@ -681,7 +683,7 @@ HttpBaseChannel::DoApplyContentConversions(nsIStreamListener* aNextListener, } } *aNewNextListener = nextListener; - NS_ADDREF(*aNewNextListener); + NS_IF_ADDREF(*aNewNextListener); return NS_OK; } diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index 2dec2ada271..392b2a62b45 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -326,17 +326,21 @@ HttpChannelChild::OnStartRequest(const nsresult& channelStatus, return; } + if (mResponseHead) + SetCookie(mResponseHead->PeekHeader(nsHttp::Set_Cookie)); + + mSelfAddr = selfAddr; + mPeerAddr = peerAddr; + if (mDivertingToParent) { mListener = nullptr; mListenerContext = nullptr; if (mLoadGroup) { mLoadGroup->RemoveRequest(this, nullptr, mStatus); } + return; } - if (mResponseHead) - SetCookie(mResponseHead->PeekHeader(nsHttp::Set_Cookie)); - nsCOMPtr listener; rv = DoApplyContentConversions(mListener, getter_AddRefs(listener), mListenerContext); @@ -345,9 +349,6 @@ HttpChannelChild::OnStartRequest(const nsresult& channelStatus, } else if (listener) { mListener = listener; } - - mSelfAddr = selfAddr; - mPeerAddr = peerAddr; } class TransportAndDataEvent : public ChannelEvent