diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index 8391d9674ac2..d0ae23c391a0 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -968,11 +968,6 @@ HttpChannelParent::DivertTo(nsIStreamListener *aListener) mDivertListener = aListener; - if (NS_WARN_IF(mIPCClosed || !SendFlushedForDiversion())) { - FailDiversion(NS_ERROR_UNEXPECTED); - return; - } - // Call OnStartRequest and SendDivertMessages asynchronously to avoid // reentering client context. NS_DispatchToCurrentThread( @@ -1020,6 +1015,11 @@ HttpChannelParent::StartDiversion() MOZ_ASSERT(NS_SUCCEEDED(rvdbg)); mDivertListener = nullptr; + if (NS_WARN_IF(mIPCClosed || !SendFlushedForDiversion())) { + FailDiversion(NS_ERROR_UNEXPECTED); + return; + } + // The listener chain should now be setup; tell HttpChannelChild to divert // the OnDataAvailables and OnStopRequest to this HttpChannelParent. if (NS_WARN_IF(mIPCClosed || !SendDivertMessages())) {