From ae7b241f265a494064d579fa42a34b564216172b Mon Sep 17 00:00:00 2001 From: Michal Novotny Date: Thu, 2 Jul 2020 16:54:34 +0000 Subject: [PATCH] Bug 1649410 - [socket-process] test_version_fallback() in netwerk/test/unit/test_http3.js fails r=necko-reviewers,kershaw Propagate Alt-Used request header set in socket process to parent process. Differential Revision: https://phabricator.services.mozilla.com/D81714 --- .../protocol/http/HttpTransactionChild.cpp | 10 ++++++- .../protocol/http/HttpTransactionParent.cpp | 29 ++++++++++++++----- netwerk/protocol/http/HttpTransactionParent.h | 5 ++-- netwerk/protocol/http/PHttpTransaction.ipdl | 3 +- netwerk/test/unit/xpcshell.ini | 3 +- 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/netwerk/protocol/http/HttpTransactionChild.cpp b/netwerk/protocol/http/HttpTransactionChild.cpp index 5318ef007d92..d254c2fb49e7 100644 --- a/netwerk/protocol/http/HttpTransactionChild.cpp +++ b/netwerk/protocol/http/HttpTransactionChild.cpp @@ -413,6 +413,13 @@ HttpTransactionChild::OnStartRequest(nsIRequest* aRequest) { } } + Maybe optionalAltSvcUsed; + nsCString altSvcUsed; + if (NS_SUCCEEDED(mTransaction->RequestHead()->GetHeader( + nsHttp::Alternate_Service_Used, altSvcUsed))) { + optionalAltSvcUsed.emplace(altSvcUsed); + } + if (CanSendODAToContentProcessDirectly(optionalHead)) { Maybe> dataBridgeParent = SocketProcessChild::GetSingleton()->GetAndRemoveDataBridge(mChannelId); @@ -444,7 +451,8 @@ HttpTransactionChild::OnStartRequest(nsIRequest* aRequest) { Unused << SendOnStartRequest(status, optionalHead, serializedSecurityInfoOut, mTransaction->ProxyConnectFailed(), ToTimingStructArgs(mTransaction->Timings()), - proxyConnectResponseCode, dataForSniffer); + proxyConnectResponseCode, dataForSniffer, + optionalAltSvcUsed); return NS_OK; } diff --git a/netwerk/protocol/http/HttpTransactionParent.cpp b/netwerk/protocol/http/HttpTransactionParent.cpp index 3b5035427a36..2c6b3df5a093 100644 --- a/netwerk/protocol/http/HttpTransactionParent.cpp +++ b/netwerk/protocol/http/HttpTransactionParent.cpp @@ -406,17 +406,17 @@ mozilla::ipc::IPCResult HttpTransactionParent::RecvOnStartRequest( const nsCString& aSecurityInfoSerialization, const bool& aProxyConnectFailed, const TimingStructArgs& aTimings, const int32_t& aProxyConnectResponseCode, - nsTArray&& aDataForSniffer) { + nsTArray&& aDataForSniffer, const Maybe& aAltSvcUsed) { mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent( - this, - [self = UnsafePtr(this), aStatus, aResponseHead, - aSecurityInfoSerialization, aProxyConnectFailed, aTimings, - aProxyConnectResponseCode, - aDataForSniffer = CopyableTArray{std::move(aDataForSniffer)}]() mutable { + this, [self = UnsafePtr(this), aStatus, + aResponseHead, aSecurityInfoSerialization, aProxyConnectFailed, + aTimings, aProxyConnectResponseCode, + aDataForSniffer = CopyableTArray{std::move(aDataForSniffer)}, + aAltSvcUsed]() mutable { self->DoOnStartRequest(aStatus, aResponseHead, aSecurityInfoSerialization, aProxyConnectFailed, aTimings, aProxyConnectResponseCode, - std::move(aDataForSniffer)); + std::move(aDataForSniffer), aAltSvcUsed); })); return IPC_OK(); } @@ -444,7 +444,7 @@ void HttpTransactionParent::DoOnStartRequest( const nsCString& aSecurityInfoSerialization, const bool& aProxyConnectFailed, const TimingStructArgs& aTimings, const int32_t& aProxyConnectResponseCode, - nsTArray&& aDataForSniffer) { + nsTArray&& aDataForSniffer, const Maybe& aAltSvcUsed) { LOG(("HttpTransactionParent::DoOnStartRequest [this=%p aStatus=%" PRIx32 "]\n", this, static_cast(aStatus))); @@ -471,6 +471,19 @@ void HttpTransactionParent::DoOnStartRequest( mProxyConnectResponseCode = aProxyConnectResponseCode; mDataForSniffer = std::move(aDataForSniffer); + nsCOMPtr httpChannel = do_QueryInterface(mChannel); + MOZ_ASSERT(httpChannel, "mChannel is expected to implement nsIHttpChannel"); + if (httpChannel) { + if (aAltSvcUsed.isSome()) { + Unused << httpChannel->SetRequestHeader( + nsDependentCString(nsHttp::Alternate_Service_Used), aAltSvcUsed.ref(), + false); + } else { + Unused << httpChannel->SetEmptyRequestHeader( + nsDependentCString(nsHttp::Alternate_Service_Used)); + } + } + AutoEventEnqueuer ensureSerialDispatch(mEventQ); nsresult rv = mChannel->OnStartRequest(this); mOnStartRequestCalled = true; diff --git a/netwerk/protocol/http/HttpTransactionParent.h b/netwerk/protocol/http/HttpTransactionParent.h index 0b6492e4e3ba..4676752b398a 100644 --- a/netwerk/protocol/http/HttpTransactionParent.h +++ b/netwerk/protocol/http/HttpTransactionParent.h @@ -52,7 +52,7 @@ class HttpTransactionParent final : public PHttpTransactionParent, const nsCString& aSecurityInfoSerialization, const bool& aProxyConnectFailed, const TimingStructArgs& aTimings, const int32_t& aProxyConnectResponseCode, - nsTArray&& aDataForSniffer); + nsTArray&& aDataForSniffer, const Maybe& aAltSvcUsed); mozilla::ipc::IPCResult RecvOnTransportStatus(const nsresult& aStatus, const int64_t& aProgress, const int64_t& aProgressMax); @@ -92,7 +92,8 @@ class HttpTransactionParent final : public PHttpTransactionParent, const bool& aProxyConnectFailed, const TimingStructArgs& aTimings, const int32_t& aProxyConnectResponseCode, - nsTArray&& aDataForSniffer); + nsTArray&& aDataForSniffer, + const Maybe& aAltSvcUsed); void DoOnTransportStatus(const nsresult& aStatus, const int64_t& aProgress, const int64_t& aProgressMax); void DoOnDataAvailable(const nsCString& aData, const uint64_t& aOffset, diff --git a/netwerk/protocol/http/PHttpTransaction.ipdl b/netwerk/protocol/http/PHttpTransaction.ipdl index 779295f49ef2..074e0970efe3 100644 --- a/netwerk/protocol/http/PHttpTransaction.ipdl +++ b/netwerk/protocol/http/PHttpTransaction.ipdl @@ -37,7 +37,8 @@ parent: bool proxyConnectFailed, TimingStructArgs timings, int32_t proxyConnectResponseCode, - uint8_t[] dataForSniffer); + uint8_t[] dataForSniffer, + nsCString? altSvcUsed); async OnTransportStatus(nsresult status, int64_t progress, int64_t progressMax); diff --git a/netwerk/test/unit/xpcshell.ini b/netwerk/test/unit/xpcshell.ini index d993dcf21a0f..ac34c7c6d550 100644 --- a/netwerk/test/unit/xpcshell.ini +++ b/netwerk/test/unit/xpcshell.ini @@ -425,8 +425,7 @@ skip-if = os == "android" # tsan - bug 1622845 # win - bug 1616238 # android - bug 1622901 -# socketprocess - bug 1649410 -skip-if = asan || tsan || os == 'win' || os =='android' || socketprocess_networking +skip-if = asan || tsan || os == 'win' || os =='android' [test_node_execute.js] [test_loadgroup_cancel.js] [test_obs-fold.js]