Bug 1067346 - Fix "apply conversion" when channel is diverted to parent. r=jduell, a=lmandel
authorDragana Damjanovic <dd.mozilla@gmail.com>
Tue, 16 Sep 2014 06:30:00 -0400
changeset 225008 fa6dc8cffc42096f171f03eaa2214df7fcddfb99
parent 225007 dd0958929b1716e3519977b496a9ee2978a410d7
child 225009 4b841e30bcd7e444a9925b0484ba5cece49accf8
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjduell, lmandel
bugs1067346
milestone34.0a2
Bug 1067346 - Fix "apply conversion" when channel is diverted to parent. r=jduell, a=lmandel
netwerk/protocol/http/HttpBaseChannel.cpp
netwerk/protocol/http/HttpChannelChild.cpp
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -605,19 +605,21 @@ HttpBaseChannel::SetApplyConversion(bool
 }
 
 NS_IMETHODIMP
 HttpBaseChannel::DoApplyContentConversions(nsIStreamListener* aNextListener,
                                            nsIStreamListener** aNewNextListener,
                                            nsISupports *aCtxt)
 {
   *aNewNextListener = nullptr;
+  if (!mResponseHead || ! aNextListener) {
+    return NS_OK;
+  }
+
   nsCOMPtr<nsIStreamListener> nextListener = aNextListener;
-  if (!mResponseHead)
-    return NS_OK;
 
   LOG(("HttpBaseChannel::DoApplyContentConversions [this=%p]\n", this));
 
   if (!mApplyConversion) {
     LOG(("not applying conversion per mApplyConversion\n"));
     return NS_OK;
   }
 
@@ -675,17 +677,17 @@ HttpBaseChannel::DoApplyContentConversio
       nextListener = converter;
     }
     else {
       if (val)
         LOG(("Unknown content encoding '%s', ignoring\n", val));
     }
   }
   *aNewNextListener = nextListener;
-  NS_ADDREF(*aNewNextListener);
+  NS_IF_ADDREF(*aNewNextListener);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HttpBaseChannel::GetContentEncodings(nsIUTF8StringEnumerator** aEncodings)
 {
   if (!mResponseHead) {
     *aEncodings = nullptr;
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -321,38 +321,39 @@ HttpChannelChild::OnStartRequest(const n
   mTracingEnabled = false;
 
   nsresult rv = mListener->OnStartRequest(this, mListenerContext);
   if (NS_FAILED(rv)) {
     Cancel(rv);
     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<nsIStreamListener> listener;
   rv = DoApplyContentConversions(mListener, getter_AddRefs(listener),
                                  mListenerContext);
   if (NS_FAILED(rv)) {
     Cancel(rv);
   } else if (listener) {
     mListener = listener;
   }
-
-  mSelfAddr = selfAddr;
-  mPeerAddr = peerAddr;
 }
 
 class TransportAndDataEvent : public ChannelEvent
 {
  public:
   TransportAndDataEvent(HttpChannelChild* child,
                         const nsresult& channelStatus,
                         const nsresult& transportStatus,