Bug 1721781 - Make HTTP3 work when we use DIRECT proxy connection, r=necko-reviewers,dragana

Differential Revision: https://phabricator.services.mozilla.com/D120805
This commit is contained in:
Kershaw Chang 2021-08-09 12:25:54 +00:00
Родитель c50c34223a
Коммит 32f8d51ddb
6 изменённых файлов: 70 добавлений и 6 удалений

Просмотреть файл

@ -5584,5 +5584,14 @@ NS_IMETHODIMP HttpBaseChannel::SetWaitForHTTPSSVCRecord() {
return NS_OK;
}
bool HttpBaseChannel::Http3Allowed() const {
bool isDirectOrNoProxy =
mProxyInfo ? static_cast<nsProxyInfo*>(mProxyInfo.get())->IsDirect()
: true;
return !mUpgradeProtocolCallback && isDirectOrNoProxy &&
!(mCaps & NS_HTTP_BE_CONSERVATIVE) && !LoadBeConservative() &&
LoadAllowHttp3();
}
} // namespace net
} // namespace mozilla

Просмотреть файл

@ -615,6 +615,8 @@ class HttpBaseChannel : public nsHashPropertyBag,
Result<bool, nsresult> EnsureOpaqueResponseIsAllowedAfterSniff();
bool Http3Allowed() const;
friend class PrivateBrowsingChannel<HttpBaseChannel>;
friend class InterceptFailedOnStop;

Просмотреть файл

@ -381,9 +381,7 @@ nsresult TRRServiceChannel::BeginConnect() {
// TODO: Bug 1622778 for using AltService in socket process.
StoreAllowAltSvc(XRE_IsParentProcess() && LoadAllowAltSvc());
bool http2Allowed = !gHttpHandler->IsHttp2Excluded(connInfo);
bool http3Allowed = !mUpgradeProtocolCallback && !mProxyInfo &&
!(mCaps & NS_HTTP_BE_CONSERVATIVE) &&
!LoadBeConservative();
bool http3Allowed = Http3Allowed();
RefPtr<AltSvcMapping> mapping;
if (!mConnectionInfo && LoadAllowAltSvc() && // per channel

Просмотреть файл

@ -5976,9 +5976,7 @@ nsresult nsHttpChannel::BeginConnect() {
if (!LoadAllowHttp3()) {
mCaps |= NS_HTTP_DISALLOW_HTTP3;
}
bool http3Allowed = !mUpgradeProtocolCallback && !mProxyInfo &&
!(mCaps & NS_HTTP_BE_CONSERVATIVE) &&
!LoadBeConservative() && LoadAllowHttp3();
bool http3Allowed = Http3Allowed();
RefPtr<AltSvcMapping> mapping;
if (!mConnectionInfo && LoadAllowAltSvc() && // per channel

Просмотреть файл

@ -0,0 +1,54 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Test if a HTTP3 connection can be established when a proxy info says
// to use direct connection
"use strict";
registerCleanupFunction(async () => {
http3_clear_prefs();
Services.prefs.clearUserPref("network.proxy.type");
Services.prefs.clearUserPref("network.proxy.autoconfig_url");
});
add_task(async function setup() {
await http3_setup_tests("h3-29");
});
function makeChan(url) {
let chan = NetUtil.newChannel({
uri: url,
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
}).QueryInterface(Ci.nsIHttpChannel);
chan.loadFlags = Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;
return chan;
}
function channelOpenPromise(chan, flags) {
return new Promise(resolve => {
function finish(req, buffer) {
resolve([req, buffer]);
}
chan.asyncOpen(new ChannelListener(finish, null, flags));
});
}
add_task(async function testHttp3WithDirectProxy() {
var pac =
"data:text/plain," +
"function FindProxyForURL(url, host) {" +
' return "DIRECT; PROXY foopy:8080;"' +
"}";
// Configure PAC
Services.prefs.setIntPref("network.proxy.type", 2);
Services.prefs.setCharPref("network.proxy.autoconfig_url", pac);
let chan = makeChan(`https://foo.example.com`);
let [req] = await channelOpenPromise(chan, CL_ALLOW_UNKNOWN_CL);
req.QueryInterface(Ci.nsIHttpChannel);
Assert.equal(req.protocolVersion, "h3-29");
});

Просмотреть файл

@ -542,3 +542,6 @@ run-sequentially = node server exceptions dont replay well
skip-if = tsan || os =='android' || (verify && (os == 'win')) || socketprocess_networking
run-sequentially = node server exceptions dont replay well
[test_304_headers.js]
[test_http3_direct_proxy.js]
skip-if = tsan || os =='android' || socketprocess_networking
run-sequentially = node server exceptions dont replay well