From 728ee84a7d36ee44682b0fd61de96f430ebf11ed Mon Sep 17 00:00:00 2001 From: Shane Caraveo Date: Tue, 10 Aug 2021 16:29:06 +0000 Subject: [PATCH] Bug 1722942 use beConservative for proxy failover to direct r=dragana,necko-reviewers Differential Revision: https://phabricator.services.mozilla.com/D121234 --- netwerk/protocol/http/nsHttpChannel.cpp | 5 ++--- .../extensions/test/xpcshell/test_proxy_failover.js | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 4c4ecb54974b..2cfef0af3374 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -2652,9 +2652,8 @@ nsresult nsHttpChannel::ProxyFailover() { return rv; } // If this request used a failed proxy and there is no failover available, - // fallback to DIRECT connections for system principal requests. - if (mLoadInfo->GetLoadingPrincipal() && - mLoadInfo->GetLoadingPrincipal()->IsSystemPrincipal()) { + // fallback to DIRECT connections for conservative requests. + if (LoadBeConservative()) { rv = pps->NewProxyInfo("direct"_ns, ""_ns, 0, ""_ns, ""_ns, 0, UINT32_MAX, nullptr, getter_AddRefs(pi)); } diff --git a/toolkit/components/extensions/test/xpcshell/test_proxy_failover.js b/toolkit/components/extensions/test/xpcshell/test_proxy_failover.js index 6bde89c6f8b7..f02bd848a7fe 100644 --- a/toolkit/components/extensions/test/xpcshell/test_proxy_failover.js +++ b/toolkit/components/extensions/test/xpcshell/test_proxy_failover.js @@ -42,8 +42,9 @@ function getBadProxyPort() { function xhr(url) { return new Promise((resolve, reject) => { - let req = new XMLHttpRequest({ mozSystem: true }); + let req = new XMLHttpRequest(); req.open("GET", `${url}?t=${Math.random()}`); + req.channel.QueryInterface(Ci.nsIHttpChannelInternal).beConservative = true; req.onload = () => { resolve(req.responseText); };