зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 8 changesets (bug 1675016) for black linting failure at runxpcshelltests.py on a CLOSED TREE
Backed out changeset 542f33bccb47 (bug 1675016) Backed out changeset ab07b3a3e2ca (bug 1675016) Backed out changeset 2c6391e0243b (bug 1675016) Backed out changeset 8100a5f39ec5 (bug 1675016) Backed out changeset c2a169663175 (bug 1675016) Backed out changeset 84cde60b4e5f (bug 1675016) Backed out changeset 29ed71c7b265 (bug 1675016) Backed out changeset 5745916ae50b (bug 1675016)
This commit is contained in:
Родитель
756e97cfb2
Коммит
67ba0c2bfb
|
@ -160,9 +160,7 @@ void AltSvcMapping::ProcessHeader(
|
||||||
SpdyInformation* spdyInfo = gHttpHandler->SpdyInfo();
|
SpdyInformation* spdyInfo = gHttpHandler->SpdyInfo();
|
||||||
if (!(NS_SUCCEEDED(spdyInfo->GetNPNIndex(npnToken, &spdyIndex)) &&
|
if (!(NS_SUCCEEDED(spdyInfo->GetNPNIndex(npnToken, &spdyIndex)) &&
|
||||||
spdyInfo->ProtocolEnabled(spdyIndex)) &&
|
spdyInfo->ProtocolEnabled(spdyIndex)) &&
|
||||||
!(isHttp3 && gHttpHandler->IsHttp3Enabled() &&
|
!(isHttp3 && gHttpHandler->IsHttp3Enabled())) {
|
||||||
!gHttpHandler->IsHttp3Excluded(hostname.IsEmpty() ? originHost
|
|
||||||
: hostname))) {
|
|
||||||
LOG(("Alt Svc unknown protocol %s, ignoring", npnToken.get()));
|
LOG(("Alt Svc unknown protocol %s, ignoring", npnToken.get()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -944,8 +942,7 @@ already_AddRefed<AltSvcMapping> AltSvcCache::LookupMapping(
|
||||||
|
|
||||||
if (rv->IsHttp3() &&
|
if (rv->IsHttp3() &&
|
||||||
(!gHttpHandler->IsHttp3Enabled() ||
|
(!gHttpHandler->IsHttp3Enabled() ||
|
||||||
!gHttpHandler->IsHttp3VersionSupported(rv->NPNToken()) ||
|
!gHttpHandler->IsHttp3VersionSupported(rv->NPNToken()))) {
|
||||||
gHttpHandler->IsHttp3Excluded(rv->AlternateHost()))) {
|
|
||||||
// If Http3 is disabled or the version not supported anymore, remove the
|
// If Http3 is disabled or the version not supported anymore, remove the
|
||||||
// mapping.
|
// mapping.
|
||||||
mStorage->Remove(
|
mStorage->Remove(
|
||||||
|
|
|
@ -73,7 +73,8 @@ Http3Session::Http3Session()
|
||||||
gHttpHandler->ConnMgr()->CurrentTopLevelOuterContentWindowId();
|
gHttpHandler->ConnMgr()->CurrentTopLevelOuterContentWindowId();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult Http3Session::Init(const nsHttpConnectionInfo* aConnInfo,
|
nsresult Http3Session::Init(const nsACString& aOrigin,
|
||||||
|
const nsACString& aAlpnToken,
|
||||||
nsISocketTransport* aSocketTransport,
|
nsISocketTransport* aSocketTransport,
|
||||||
HttpConnectionUDP* readerWriter) {
|
HttpConnectionUDP* readerWriter) {
|
||||||
LOG3(("Http3Session::Init %p", this));
|
LOG3(("Http3Session::Init %p", this));
|
||||||
|
@ -82,7 +83,7 @@ nsresult Http3Session::Init(const nsHttpConnectionInfo* aConnInfo,
|
||||||
MOZ_ASSERT(aSocketTransport);
|
MOZ_ASSERT(aSocketTransport);
|
||||||
MOZ_ASSERT(readerWriter);
|
MOZ_ASSERT(readerWriter);
|
||||||
|
|
||||||
mConnInfo = aConnInfo->Clone();
|
mAlpnToken = aAlpnToken;
|
||||||
mSocketTransport = aSocketTransport;
|
mSocketTransport = aSocketTransport;
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> info;
|
nsCOMPtr<nsISupports> info;
|
||||||
|
@ -136,14 +137,14 @@ nsresult Http3Session::Init(const nsHttpConnectionInfo* aConnInfo,
|
||||||
LOG3(
|
LOG3(
|
||||||
("Http3Session::Init origin=%s, alpn=%s, selfAddr=%s, peerAddr=%s,"
|
("Http3Session::Init origin=%s, alpn=%s, selfAddr=%s, peerAddr=%s,"
|
||||||
" qpack table size=%u, max blocked streams=%u [this=%p]",
|
" qpack table size=%u, max blocked streams=%u [this=%p]",
|
||||||
PromiseFlatCString(mConnInfo->GetOrigin()).get(),
|
PromiseFlatCString(aOrigin).get(), PromiseFlatCString(aAlpnToken).get(),
|
||||||
PromiseFlatCString(mConnInfo->GetNPNToken()).get(), selfAddrStr.get(),
|
selfAddrStr.get(), peerAddrStr.get(),
|
||||||
peerAddrStr.get(), gHttpHandler->DefaultQpackTableSize(),
|
gHttpHandler->DefaultQpackTableSize(),
|
||||||
gHttpHandler->DefaultHttp3MaxBlockedStreams(), this));
|
gHttpHandler->DefaultHttp3MaxBlockedStreams(), this));
|
||||||
|
|
||||||
nsresult rv = NeqoHttp3Conn::Init(
|
nsresult rv = NeqoHttp3Conn::Init(
|
||||||
mConnInfo->GetOrigin(), mConnInfo->GetNPNToken(), selfAddrStr,
|
aOrigin, aAlpnToken, selfAddrStr, peerAddrStr,
|
||||||
peerAddrStr, gHttpHandler->DefaultQpackTableSize(),
|
gHttpHandler->DefaultQpackTableSize(),
|
||||||
gHttpHandler->DefaultHttp3MaxBlockedStreams(),
|
gHttpHandler->DefaultHttp3MaxBlockedStreams(),
|
||||||
gHttpHandler->Http3QlogDir(), getter_AddRefs(mHttp3Connection));
|
gHttpHandler->Http3QlogDir(), getter_AddRefs(mHttp3Connection));
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
@ -186,11 +187,6 @@ nsresult Http3Session::Init(const nsHttpConnectionInfo* aConnInfo,
|
||||||
void Http3Session::Shutdown() {
|
void Http3Session::Shutdown() {
|
||||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
||||||
|
|
||||||
if ((mBeforeConnectedError || (mError == NS_ERROR_NET_HTTP3_PROTOCOL_ERROR)) &&
|
|
||||||
(mError != mozilla::psm::GetXPCOMFromNSSError(SSL_ERROR_BAD_CERT_DOMAIN))) {
|
|
||||||
gHttpHandler->ExcludeHttp3(mConnInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto iter = mStreamTransactionHash.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mStreamTransactionHash.Iter(); !iter.Done(); iter.Next()) {
|
||||||
RefPtr<Http3Stream> stream = iter.Data();
|
RefPtr<Http3Stream> stream = iter.Data();
|
||||||
|
|
||||||
|
@ -199,12 +195,10 @@ void Http3Session::Shutdown() {
|
||||||
// The transaction restart code path will remove AltSvc mapping and the
|
// The transaction restart code path will remove AltSvc mapping and the
|
||||||
// direct path will be used.
|
// direct path will be used.
|
||||||
MOZ_ASSERT(NS_FAILED(mError));
|
MOZ_ASSERT(NS_FAILED(mError));
|
||||||
stream->Close(NS_ERROR_NET_RESET);
|
stream->Close(mError);
|
||||||
} else if (!stream->HasStreamId()) {
|
} else if (!stream->HasStreamId()) {
|
||||||
if (NS_SUCCEEDED(mError)) {
|
// Connection has not been started yet. We can restart it.
|
||||||
// Connection has not been started yet. We can restart it.
|
stream->Transaction()->DoNotRemoveAltSvc();
|
||||||
stream->Transaction()->DoNotRemoveAltSvc();
|
|
||||||
}
|
|
||||||
stream->Close(NS_ERROR_NET_RESET);
|
stream->Close(NS_ERROR_NET_RESET);
|
||||||
} else if (stream->RecvdData()) {
|
} else if (stream->RecvdData()) {
|
||||||
stream->Close(NS_ERROR_NET_PARTIAL_TRANSFER);
|
stream->Close(NS_ERROR_NET_PARTIAL_TRANSFER);
|
||||||
|
@ -842,8 +836,7 @@ void Http3Session::ResetRecvd(uint64_t aStreamId, uint64_t aError) {
|
||||||
if (aError == HTTP3_APP_ERROR_VERSION_FALLBACK) {
|
if (aError == HTTP3_APP_ERROR_VERSION_FALLBACK) {
|
||||||
// We will restart the request and the alt-svc will be removed
|
// We will restart the request and the alt-svc will be removed
|
||||||
// automatically.
|
// automatically.
|
||||||
// Also disable http3 we want http1.1.
|
// Also disable spdy we want http/1.1.
|
||||||
stream->Transaction()->DisableHttp3();
|
|
||||||
stream->Transaction()->DisableSpdy();
|
stream->Transaction()->DisableSpdy();
|
||||||
CloseStream(stream, NS_ERROR_NET_RESET);
|
CloseStream(stream, NS_ERROR_NET_RESET);
|
||||||
} else if (aError == HTTP3_APP_ERROR_REQUEST_REJECTED) {
|
} else if (aError == HTTP3_APP_ERROR_REQUEST_REJECTED) {
|
||||||
|
@ -1481,11 +1474,11 @@ bool Http3Session::RealJoinConnection(const nsACString& hostname, int32_t port,
|
||||||
|
|
||||||
bool joinedReturn = false;
|
bool joinedReturn = false;
|
||||||
if (justKidding) {
|
if (justKidding) {
|
||||||
rv = sslSocketControl->TestJoinConnection(mConnInfo->GetNPNToken(),
|
rv = sslSocketControl->TestJoinConnection(mAlpnToken, hostname, port,
|
||||||
hostname, port, &isJoined);
|
&isJoined);
|
||||||
} else {
|
} else {
|
||||||
rv = sslSocketControl->JoinConnection(mConnInfo->GetNPNToken(), hostname,
|
rv =
|
||||||
port, &isJoined);
|
sslSocketControl->JoinConnection(mAlpnToken, hostname, port, &isJoined);
|
||||||
}
|
}
|
||||||
if (NS_SUCCEEDED(rv) && isJoined) {
|
if (NS_SUCCEEDED(rv) && isJoined) {
|
||||||
joinedReturn = true;
|
joinedReturn = true;
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Http3Session final : public nsAHttpTransaction,
|
||||||
NS_DECL_NSAHTTPSEGMENTWRITER
|
NS_DECL_NSAHTTPSEGMENTWRITER
|
||||||
|
|
||||||
Http3Session();
|
Http3Session();
|
||||||
nsresult Init(const nsHttpConnectionInfo* aConnInfo,
|
nsresult Init(const nsACString& aOrigin, const nsACString& aAlpnToken,
|
||||||
nsISocketTransport* aSocketTransport,
|
nsISocketTransport* aSocketTransport,
|
||||||
HttpConnectionUDP* readerWriter);
|
HttpConnectionUDP* readerWriter);
|
||||||
|
|
||||||
|
@ -206,8 +206,6 @@ class Http3Session final : public nsAHttpTransaction,
|
||||||
// NS_NET_STATUS_CONNECTED_TO event will be created by the Http3Session.
|
// NS_NET_STATUS_CONNECTED_TO event will be created by the Http3Session.
|
||||||
// We want to propagate it to the first transaction.
|
// We want to propagate it to the first transaction.
|
||||||
RefPtr<nsHttpTransaction> mFirstHttpTransaction;
|
RefPtr<nsHttpTransaction> mFirstHttpTransaction;
|
||||||
|
|
||||||
RefPtr<nsHttpConnectionInfo> mConnInfo;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_DEFINE_STATIC_IID_ACCESSOR(Http3Session, NS_HTTP3SESSION_IID);
|
NS_DEFINE_STATIC_IID_ACCESSOR(Http3Session, NS_HTTP3SESSION_IID);
|
||||||
|
|
|
@ -115,7 +115,8 @@ nsresult HttpConnectionUDP::Init(
|
||||||
|
|
||||||
MOZ_ASSERT(mConnInfo->IsHttp3());
|
MOZ_ASSERT(mConnInfo->IsHttp3());
|
||||||
mHttp3Session = new Http3Session();
|
mHttp3Session = new Http3Session();
|
||||||
nsresult rv = mHttp3Session->Init(mConnInfo, mSocketTransport, this);
|
nsresult rv = mHttp3Session->Init(
|
||||||
|
mConnInfo->GetOrigin(), mConnInfo->GetNPNToken(), mSocketTransport, this);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
LOG(
|
LOG(
|
||||||
("HttpConnectionUDP::Init mHttp3Session->Init failed "
|
("HttpConnectionUDP::Init mHttp3Session->Init failed "
|
||||||
|
|
|
@ -396,7 +396,8 @@ nsresult TRRServiceChannel::BeginConnect() {
|
||||||
mAllowAltSvc = XRE_IsParentProcess() && mAllowAltSvc;
|
mAllowAltSvc = XRE_IsParentProcess() && mAllowAltSvc;
|
||||||
bool http2Allowed = !gHttpHandler->IsHttp2Excluded(connInfo);
|
bool http2Allowed = !gHttpHandler->IsHttp2Excluded(connInfo);
|
||||||
bool http3Allowed = !mUpgradeProtocolCallback && !mProxyInfo &&
|
bool http3Allowed = !mUpgradeProtocolCallback && !mProxyInfo &&
|
||||||
!(mCaps & NS_HTTP_BE_CONSERVATIVE) && !mBeConservative;
|
!(mCaps & NS_HTTP_BE_CONSERVATIVE) && !mBeConservative &&
|
||||||
|
!gHttpHandler->IsHttp3Excluded(connInfo);
|
||||||
|
|
||||||
RefPtr<AltSvcMapping> mapping;
|
RefPtr<AltSvcMapping> mapping;
|
||||||
if (!mConnectionInfo && mAllowAltSvc && // per channel
|
if (!mConnectionInfo && mAllowAltSvc && // per channel
|
||||||
|
|
|
@ -178,7 +178,6 @@ class nsAHttpTransaction : public nsSupportsWeakReference {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void DisableSpdy() {}
|
virtual void DisableSpdy() {}
|
||||||
virtual void DisableHttp3() {}
|
|
||||||
virtual void MakeNonSticky() {}
|
virtual void MakeNonSticky() {}
|
||||||
virtual void ReuseConnectionOnRestartOK(bool) {}
|
virtual void ReuseConnectionOnRestartOK(bool) {}
|
||||||
|
|
||||||
|
|
|
@ -6672,7 +6672,7 @@ nsresult nsHttpChannel::BeginConnect() {
|
||||||
}
|
}
|
||||||
bool http3Allowed = !mUpgradeProtocolCallback && !mProxyInfo &&
|
bool http3Allowed = !mUpgradeProtocolCallback && !mProxyInfo &&
|
||||||
!(mCaps & NS_HTTP_BE_CONSERVATIVE) && !mBeConservative &&
|
!(mCaps & NS_HTTP_BE_CONSERVATIVE) && !mBeConservative &&
|
||||||
mAllowHttp3;
|
!gHttpHandler->IsHttp3Excluded(connInfo) && mAllowHttp3;
|
||||||
|
|
||||||
// No need to lookup HTTPSSVC record if we already have one.
|
// No need to lookup HTTPSSVC record if we already have one.
|
||||||
mUseHTTPSSVC =
|
mUseHTTPSSVC =
|
||||||
|
|
|
@ -2851,15 +2851,15 @@ void nsHttpHandler::ExcludeHttp3(const nsHttpConnectionInfo* ci) {
|
||||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
||||||
|
|
||||||
mConnMgr->ExcludeHttp3(ci);
|
mConnMgr->ExcludeHttp3(ci);
|
||||||
if (!mExcludedHttp3Origins.Contains(ci->GetRoutedHost())) {
|
if (!mExcludedHttp3Origins.Contains(ci->GetOrigin())) {
|
||||||
MutexAutoLock lock(mHttpExclusionLock);
|
MutexAutoLock lock(mHttpExclusionLock);
|
||||||
mExcludedHttp3Origins.PutEntry(ci->GetRoutedHost());
|
mExcludedHttp3Origins.PutEntry(ci->GetOrigin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nsHttpHandler::IsHttp3Excluded(const nsACString& aRoutedHost) {
|
bool nsHttpHandler::IsHttp3Excluded(const nsHttpConnectionInfo* ci) {
|
||||||
MutexAutoLock lock(mHttpExclusionLock);
|
MutexAutoLock lock(mHttpExclusionLock);
|
||||||
return mExcludedHttp3Origins.Contains(aRoutedHost);
|
return mExcludedHttp3Origins.Contains(ci->GetOrigin());
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpTrafficAnalyzer* nsHttpHandler::GetHttpTrafficAnalyzer() {
|
HttpTrafficAnalyzer* nsHttpHandler::GetHttpTrafficAnalyzer() {
|
||||||
|
|
|
@ -855,7 +855,7 @@ class nsHttpHandler final : public nsIHttpProtocolHandler,
|
||||||
void ExcludeHttp2(const nsHttpConnectionInfo* ci);
|
void ExcludeHttp2(const nsHttpConnectionInfo* ci);
|
||||||
[[nodiscard]] bool IsHttp2Excluded(const nsHttpConnectionInfo* ci);
|
[[nodiscard]] bool IsHttp2Excluded(const nsHttpConnectionInfo* ci);
|
||||||
void ExcludeHttp3(const nsHttpConnectionInfo* ci);
|
void ExcludeHttp3(const nsHttpConnectionInfo* ci);
|
||||||
[[nodiscard]] bool IsHttp3Excluded(const nsACString& aRoutedHost);
|
[[nodiscard]] bool IsHttp3Excluded(const nsHttpConnectionInfo* ci);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsTHashtable<nsCStringHashKey> mExcludedHttp2Origins;
|
nsTHashtable<nsCStringHashKey> mExcludedHttp2Origins;
|
||||||
|
|
|
@ -2413,11 +2413,6 @@ void nsHttpTransaction::DisableHttp3() {
|
||||||
// After CloneAsDirectRoute(), http3 will be disabled.
|
// After CloneAsDirectRoute(), http3 will be disabled.
|
||||||
RefPtr<nsHttpConnectionInfo> connInfo;
|
RefPtr<nsHttpConnectionInfo> connInfo;
|
||||||
mConnInfo->CloneAsDirectRoute(getter_AddRefs(connInfo));
|
mConnInfo->CloneAsDirectRoute(getter_AddRefs(connInfo));
|
||||||
if (mRequestHead) {
|
|
||||||
DebugOnly<nsresult> rv =
|
|
||||||
mRequestHead->SetHeader(nsHttp::Alternate_Service_Used, "0"_ns);
|
|
||||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
||||||
}
|
|
||||||
MOZ_ASSERT(!connInfo->IsHttp3());
|
MOZ_ASSERT(!connInfo->IsHttp3());
|
||||||
mConnInfo.swap(connInfo);
|
mConnInfo.swap(connInfo);
|
||||||
}
|
}
|
||||||
|
@ -2808,11 +2803,6 @@ nsresult nsHttpTransaction::RestartOnFastOpenError() {
|
||||||
RefPtr<nsHttpConnectionInfo> ci;
|
RefPtr<nsHttpConnectionInfo> ci;
|
||||||
mConnInfo->CloneAsDirectRoute(getter_AddRefs(ci));
|
mConnInfo->CloneAsDirectRoute(getter_AddRefs(ci));
|
||||||
mConnInfo = ci;
|
mConnInfo = ci;
|
||||||
if (mRequestHead) {
|
|
||||||
DebugOnly<nsresult> rv =
|
|
||||||
mRequestHead->SetHeader(nsHttp::Alternate_Service_Used, "0"_ns);
|
|
||||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mEarlyDataDisposition = EARLY_NONE;
|
mEarlyDataDisposition = EARLY_NONE;
|
||||||
m0RTTInProgress = false;
|
m0RTTInProgress = false;
|
||||||
|
|
|
@ -103,7 +103,7 @@ class nsHttpTransaction final : public nsAHttpTransaction,
|
||||||
void RemoveDispatchedAsBlocking();
|
void RemoveDispatchedAsBlocking();
|
||||||
|
|
||||||
void DisableSpdy() override;
|
void DisableSpdy() override;
|
||||||
void DisableHttp3() override;
|
void DisableHttp3();
|
||||||
|
|
||||||
nsHttpTransaction* QueryHttpTransaction() override { return this; }
|
nsHttpTransaction* QueryHttpTransaction() override { return this; }
|
||||||
|
|
||||||
|
|
|
@ -297,23 +297,6 @@ impl HttpServer for Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
struct NonRespondingServer {}
|
|
||||||
|
|
||||||
impl ::std::fmt::Display for NonRespondingServer {
|
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
|
||||||
write!(f, "NonRespondingServer")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl HttpServer for NonRespondingServer {
|
|
||||||
fn process(&mut self, _dgram: Option<Datagram>) -> Output {
|
|
||||||
Output::None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn process_events(&mut self) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn emit_packet(socket: &UdpSocket, out_dgram: Datagram) {
|
fn emit_packet(socket: &UdpSocket, out_dgram: Datagram) {
|
||||||
let sent = socket
|
let sent = socket
|
||||||
.send_to(&out_dgram, &out_dgram.destination())
|
.send_to(&out_dgram, &out_dgram.destination())
|
||||||
|
@ -378,12 +361,6 @@ fn read_dgram(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ServerType {
|
|
||||||
Http3,
|
|
||||||
Http3Fail,
|
|
||||||
Http3NoResponse,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ServersRunner {
|
struct ServersRunner {
|
||||||
hosts: Vec<SocketAddr>,
|
hosts: Vec<SocketAddr>,
|
||||||
poll: Poll,
|
poll: Poll,
|
||||||
|
@ -408,21 +385,19 @@ impl ServersRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(&mut self) {
|
pub fn init(&mut self) {
|
||||||
self.add_new_socket(0, ServerType::Http3);
|
self.add_new_socket(0, true);
|
||||||
self.add_new_socket(1, ServerType::Http3Fail);
|
self.add_new_socket(1, false);
|
||||||
self.add_new_socket(3, ServerType::Http3NoResponse);
|
|
||||||
println!(
|
println!(
|
||||||
"HTTP3 server listening on ports {}, {} and {}",
|
"HTTP3 server listening on ports {} and {}",
|
||||||
self.hosts[0].port(),
|
self.hosts[0].port(),
|
||||||
self.hosts[1].port(),
|
self.hosts[1].port()
|
||||||
self.hosts[2].port()
|
|
||||||
);
|
);
|
||||||
self.poll
|
self.poll
|
||||||
.register(&self.timer, TIMER_TOKEN, Ready::readable(), PollOpt::edge())
|
.register(&self.timer, TIMER_TOKEN, Ready::readable(), PollOpt::edge())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_new_socket(&mut self, count: usize, server_type: ServerType) -> u16 {
|
fn add_new_socket(&mut self, count: usize, http3: bool) -> u16 {
|
||||||
let addr = "127.0.0.1:0".parse().unwrap();
|
let addr = "127.0.0.1:0".parse().unwrap();
|
||||||
|
|
||||||
let socket = match UdpSocket::bind(&addr) {
|
let socket = match UdpSocket::bind(&addr) {
|
||||||
|
@ -454,17 +429,17 @@ impl ServersRunner {
|
||||||
|
|
||||||
self.sockets.push(socket);
|
self.sockets.push(socket);
|
||||||
self.servers
|
self.servers
|
||||||
.insert(local_addr, (self.create_server(server_type), None));
|
.insert(local_addr, (self.create_server(http3), None));
|
||||||
local_addr.port()
|
local_addr.port()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_server(&self, server_type: ServerType) -> Box<dyn HttpServer> {
|
fn create_server(&self, http3: bool) -> Box<dyn HttpServer> {
|
||||||
let anti_replay = AntiReplay::new(Instant::now(), Duration::from_secs(10), 7, 14)
|
let anti_replay = AntiReplay::new(Instant::now(), Duration::from_secs(10), 7, 14)
|
||||||
.expect("unable to setup anti-replay");
|
.expect("unable to setup anti-replay");
|
||||||
let cid_mgr = Rc::new(RefCell::new(FixedConnectionIdManager::new(10)));
|
let cid_mgr = Rc::new(RefCell::new(FixedConnectionIdManager::new(10)));
|
||||||
|
|
||||||
match server_type {
|
if http3 {
|
||||||
ServerType::Http3 => Box::new(Http3TestServer::new(
|
Box::new(Http3TestServer::new(
|
||||||
Http3Server::new(
|
Http3Server::new(
|
||||||
Instant::now(),
|
Instant::now(),
|
||||||
&[" HTTP2 Test Cert"],
|
&[" HTTP2 Test Cert"],
|
||||||
|
@ -478,8 +453,9 @@ impl ServersRunner {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.expect("We cannot make a server!"),
|
.expect("We cannot make a server!"),
|
||||||
)),
|
))
|
||||||
ServerType::Http3Fail => Box::new(
|
} else {
|
||||||
|
Box::new(
|
||||||
Server::new(
|
Server::new(
|
||||||
Instant::now(),
|
Instant::now(),
|
||||||
&[" HTTP2 Test Cert"],
|
&[" HTTP2 Test Cert"],
|
||||||
|
@ -489,8 +465,7 @@ impl ServersRunner {
|
||||||
cid_mgr,
|
cid_mgr,
|
||||||
)
|
)
|
||||||
.expect("We cannot make a server!"),
|
.expect("We cannot make a server!"),
|
||||||
),
|
)
|
||||||
ServerType::Http3NoResponse => Box::new(NonRespondingServer::default()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,121 +0,0 @@
|
||||||
/* 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/. */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
let httpsUri;
|
|
||||||
|
|
||||||
registerCleanupFunction(async () => {
|
|
||||||
Services.prefs.clearUserPref("network.http.http3.enabled");
|
|
||||||
Services.prefs.clearUserPref("network.dns.localDomains");
|
|
||||||
Services.prefs.clearUserPref("network.dns.disableIPv6");
|
|
||||||
Services.prefs.clearUserPref(
|
|
||||||
"network.http.http3.alt-svc-mapping-for-testing"
|
|
||||||
);
|
|
||||||
dump("cleanup done\n");
|
|
||||||
});
|
|
||||||
|
|
||||||
function chanPromise(chan, listener) {
|
|
||||||
return new Promise(resolve => {
|
|
||||||
function finish() {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
listener.finish = finish;
|
|
||||||
chan.asyncOpen(listener);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeChan() {
|
|
||||||
let chan = NetUtil.newChannel({
|
|
||||||
uri: httpsUri,
|
|
||||||
loadUsingSystemPrincipal: true,
|
|
||||||
}).QueryInterface(Ci.nsIHttpChannel);
|
|
||||||
chan.loadFlags = Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;
|
|
||||||
return chan;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_task(async function test_setup() {
|
|
||||||
let env = Cc["@mozilla.org/process/environment;1"].getService(
|
|
||||||
Ci.nsIEnvironment
|
|
||||||
);
|
|
||||||
|
|
||||||
let h2Port = env.get("MOZHTTP2_PORT");
|
|
||||||
Assert.notEqual(h2Port, null);
|
|
||||||
let h3Port = env.get("MOZHTTP3_PORT_NO_RESPONSE");
|
|
||||||
Assert.notEqual(h3Port, null);
|
|
||||||
Assert.notEqual(h3Port, "");
|
|
||||||
|
|
||||||
Services.prefs.setBoolPref("network.http.http3.enabled", true);
|
|
||||||
Services.prefs.setCharPref("network.dns.localDomains", "foo.example.com");
|
|
||||||
Services.prefs.setBoolPref("network.dns.disableIPv6", true);
|
|
||||||
// Set AltSvc to point to not existing HTTP3 server on port 443
|
|
||||||
Services.prefs.setCharPref(
|
|
||||||
"network.http.http3.alt-svc-mapping-for-testing",
|
|
||||||
"foo.example.com;h3-27=:" + h3Port
|
|
||||||
);
|
|
||||||
|
|
||||||
let certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(
|
|
||||||
Ci.nsIX509CertDB
|
|
||||||
);
|
|
||||||
addCertFromFile(certdb, "http2-ca.pem", "CTu,u,u");
|
|
||||||
|
|
||||||
httpsUri = "https://foo.example.com:" + h2Port + "/";
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_fatal_stream_error() {
|
|
||||||
let result = 1;
|
|
||||||
// We need to loop here because we need to wait for AltSvc storage to
|
|
||||||
// to be started.
|
|
||||||
// We also do not have a way to verify that HTTP3 has been tried, because
|
|
||||||
// the fallback is automatic, so try a couple of times.
|
|
||||||
do {
|
|
||||||
// We need to close HTTP2 connections, otherwise our connection pooling
|
|
||||||
// will dispatch the request over already existing HTTP2 connection.
|
|
||||||
Services.obs.notifyObservers(null, "net:prune-all-connections");
|
|
||||||
let chan = makeChan();
|
|
||||||
let listener = new CheckOnlyHttp2Listener();
|
|
||||||
await altsvcSetupPromise(chan, listener);
|
|
||||||
result++;
|
|
||||||
} while (result < 5);
|
|
||||||
});
|
|
||||||
|
|
||||||
let CheckOnlyHttp2Listener = function() {};
|
|
||||||
|
|
||||||
CheckOnlyHttp2Listener.prototype = {
|
|
||||||
onStartRequest: function testOnStartRequest(request) {},
|
|
||||||
|
|
||||||
onDataAvailable: function testOnDataAvailable(request, stream, off, cnt) {
|
|
||||||
read_stream(stream, cnt);
|
|
||||||
},
|
|
||||||
|
|
||||||
onStopRequest: function testOnStopRequest(request, status) {
|
|
||||||
Assert.equal(status, Cr.NS_OK);
|
|
||||||
let httpVersion = "";
|
|
||||||
try {
|
|
||||||
httpVersion = request.protocolVersion;
|
|
||||||
} catch (e) {}
|
|
||||||
Assert.equal(httpVersion, "h2");
|
|
||||||
|
|
||||||
let routed = "NA";
|
|
||||||
try {
|
|
||||||
routed = request.getRequestHeader("Alt-Used");
|
|
||||||
} catch (e) {}
|
|
||||||
dump("routed is " + routed + "\n");
|
|
||||||
Assert.ok(routed === "0" || routed === "NA");
|
|
||||||
this.finish();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
add_task(async function test_no_http3_after_error() {
|
|
||||||
let chan = makeChan();
|
|
||||||
let listener = new CheckOnlyHttp2Listener();
|
|
||||||
await altsvcSetupPromise(chan, listener);
|
|
||||||
});
|
|
||||||
|
|
||||||
// also after all connections are closed.
|
|
||||||
add_task(async function test_no_http3_after_error2() {
|
|
||||||
Services.obs.notifyObservers(null, "net:prune-all-connections");
|
|
||||||
let chan = makeChan();
|
|
||||||
let listener = new CheckOnlyHttp2Listener();
|
|
||||||
await altsvcSetupPromise(chan, listener);
|
|
||||||
});
|
|
|
@ -1,147 +1,141 @@
|
||||||
/* 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/. */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
let httpsUri;
|
let h3Port;
|
||||||
|
let h3Route;
|
||||||
|
let h3AltSvc;
|
||||||
|
let prefs;
|
||||||
|
let httpsOrigin;
|
||||||
|
|
||||||
registerCleanupFunction(async () => {
|
let tests = [
|
||||||
Services.prefs.clearUserPref("network.http.http3.enabled");
|
// The altSvc storage may not be up imediately, therefore run test_no_altsvc_pref
|
||||||
Services.prefs.clearUserPref("network.dns.localDomains");
|
// for a couple times to wait for the storage.
|
||||||
Services.prefs.clearUserPref("network.dns.disableIPv6");
|
test_no_altsvc_pref,
|
||||||
Services.prefs.clearUserPref(
|
test_no_altsvc_pref,
|
||||||
"network.http.http3.alt-svc-mapping-for-testing"
|
test_no_altsvc_pref,
|
||||||
|
test_protocol_error,
|
||||||
|
testsDone,
|
||||||
|
];
|
||||||
|
|
||||||
|
let current_test = 0;
|
||||||
|
|
||||||
|
function run_next_test() {
|
||||||
|
if (current_test < tests.length) {
|
||||||
|
dump("starting test number " + current_test + "\n");
|
||||||
|
tests[current_test]();
|
||||||
|
current_test++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_test() {
|
||||||
|
let env = Cc["@mozilla.org/process/environment;1"].getService(
|
||||||
|
Ci.nsIEnvironment
|
||||||
);
|
);
|
||||||
dump("cleanup done\n");
|
h3Port = env.get("MOZHTTP3_PORT_FAILED");
|
||||||
});
|
Assert.notEqual(h3Port, null);
|
||||||
|
Assert.notEqual(h3Port, "");
|
||||||
|
h3AltSvc = ":" + h3Port;
|
||||||
|
|
||||||
let Http3FailedListener = function() {};
|
h3Route = "foo.example.com:" + h3Port;
|
||||||
|
do_get_profile();
|
||||||
|
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||||
|
|
||||||
Http3FailedListener.prototype = {
|
prefs.setBoolPref("network.http.http3.enabled", true);
|
||||||
onStartRequest: function testOnStartRequest(request) {},
|
prefs.setCharPref("network.dns.localDomains", "foo.example.com");
|
||||||
|
prefs.setBoolPref("network.dns.disableIPv6", true);
|
||||||
|
|
||||||
|
// The certificate for the http3server server is for foo.example.com and
|
||||||
|
// is signed by http2-ca.pem so add that cert to the trust list as a
|
||||||
|
// signing cert.
|
||||||
|
let certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(
|
||||||
|
Ci.nsIX509CertDB
|
||||||
|
);
|
||||||
|
addCertFromFile(certdb, "http2-ca.pem", "CTu,u,u");
|
||||||
|
httpsOrigin = "https://foo.example.com/";
|
||||||
|
|
||||||
|
run_next_test();
|
||||||
|
}
|
||||||
|
|
||||||
|
let Http3CheckListener = function() {};
|
||||||
|
|
||||||
|
Http3CheckListener.prototype = {
|
||||||
|
expectedRoute: "",
|
||||||
|
expectedStatus: Cr.NS_OK,
|
||||||
|
|
||||||
|
onStartRequest: function testOnStartRequest(request) {
|
||||||
|
Assert.ok(request instanceof Ci.nsIHttpChannel);
|
||||||
|
Assert.equal(request.status, this.expectedStatus);
|
||||||
|
if (Components.isSuccessCode(this.expectedStatus)) {
|
||||||
|
Assert.equal(request.responseStatus, 200);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onDataAvailable: function testOnDataAvailable(request, stream, off, cnt) {
|
onDataAvailable: function testOnDataAvailable(request, stream, off, cnt) {
|
||||||
this.amount += cnt;
|
|
||||||
read_stream(stream, cnt);
|
read_stream(stream, cnt);
|
||||||
},
|
},
|
||||||
|
|
||||||
onStopRequest: function testOnStopRequest(request, status) {
|
onStopRequest: function testOnStopRequest(request, status) {
|
||||||
if (Components.isSuccessCode(status)) {
|
Assert.equal(status, this.expectedStatus);
|
||||||
// This is still HTTP2 connection
|
if (Components.isSuccessCode(this.expectedStatus)) {
|
||||||
|
Assert.equal(request.responseStatus, 200);
|
||||||
|
let routed = "NA";
|
||||||
|
try {
|
||||||
|
routed = request.getRequestHeader("Alt-Used");
|
||||||
|
} catch (e) {}
|
||||||
|
dump("routed is " + routed + "\n");
|
||||||
|
|
||||||
|
Assert.equal(routed, this.expectedRoute);
|
||||||
|
|
||||||
let httpVersion = "";
|
let httpVersion = "";
|
||||||
try {
|
try {
|
||||||
httpVersion = request.protocolVersion;
|
httpVersion = request.protocolVersion;
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
Assert.equal(httpVersion, "h2");
|
Assert.equal(httpVersion, "h3");
|
||||||
this.finish(false);
|
|
||||||
} else {
|
|
||||||
Assert.equal(status, Cr.NS_ERROR_NET_PARTIAL_TRANSFER);
|
|
||||||
this.finish(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_next_test();
|
||||||
|
do_test_finished();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function chanPromise(chan, listener) {
|
function makeChan(uri) {
|
||||||
return new Promise(resolve => {
|
|
||||||
function finish(result) {
|
|
||||||
resolve(result);
|
|
||||||
}
|
|
||||||
listener.finish = finish;
|
|
||||||
chan.asyncOpen(listener);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeChan() {
|
|
||||||
let chan = NetUtil.newChannel({
|
let chan = NetUtil.newChannel({
|
||||||
uri: httpsUri,
|
uri,
|
||||||
loadUsingSystemPrincipal: true,
|
loadUsingSystemPrincipal: true,
|
||||||
}).QueryInterface(Ci.nsIHttpChannel);
|
}).QueryInterface(Ci.nsIHttpChannel);
|
||||||
chan.loadFlags = Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;
|
chan.loadFlags = Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;
|
||||||
return chan;
|
return chan;
|
||||||
}
|
}
|
||||||
|
|
||||||
function altsvcSetupPromise(chan, listener) {
|
function test_no_altsvc_pref() {
|
||||||
return new Promise(resolve => {
|
dump("test_no_altsvc_pref");
|
||||||
function finish(result) {
|
do_test_pending();
|
||||||
resolve(result);
|
|
||||||
}
|
let chan = makeChan(httpsOrigin + "http3-test");
|
||||||
listener.finish = finish;
|
let listener = new Http3CheckListener();
|
||||||
chan.asyncOpen(listener);
|
listener.expectedStatus = Cr.NS_ERROR_CONNECTION_REFUSED;
|
||||||
});
|
chan.asyncOpen(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_task(async function test_fatal_error() {
|
function test_protocol_error() {
|
||||||
let env = Cc["@mozilla.org/process/environment;1"].getService(
|
dump("test_protocol_error");
|
||||||
Ci.nsIEnvironment
|
do_test_pending();
|
||||||
);
|
|
||||||
|
|
||||||
let h2Port = env.get("MOZHTTP2_PORT");
|
prefs.setCharPref(
|
||||||
Assert.notEqual(h2Port, null);
|
|
||||||
|
|
||||||
let h3Port = env.get("MOZHTTP3_PORT_FAILED");
|
|
||||||
Assert.notEqual(h3Port, null);
|
|
||||||
Assert.notEqual(h3Port, "");
|
|
||||||
|
|
||||||
Services.prefs.setBoolPref("network.http.http3.enabled", true);
|
|
||||||
Services.prefs.setCharPref("network.dns.localDomains", "foo.example.com");
|
|
||||||
Services.prefs.setBoolPref("network.dns.disableIPv6", true);
|
|
||||||
Services.prefs.setCharPref(
|
|
||||||
"network.http.http3.alt-svc-mapping-for-testing",
|
"network.http.http3.alt-svc-mapping-for-testing",
|
||||||
"foo.example.com;h3-27=:" + h3Port
|
"foo.example.com;h3-27=" + h3AltSvc
|
||||||
);
|
);
|
||||||
|
|
||||||
let certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(
|
let chan = makeChan(httpsOrigin + "wrong_frame_after_data_frame");
|
||||||
Ci.nsIX509CertDB
|
let listener = new Http3CheckListener();
|
||||||
);
|
listener.expectedRoute = h3Route;
|
||||||
addCertFromFile(certdb, "http2-ca.pem", "CTu,u,u");
|
listener.expectedStatus = Cr.NS_ERROR_NET_PARTIAL_TRANSFER;
|
||||||
|
chan.asyncOpen(listener);
|
||||||
|
}
|
||||||
|
|
||||||
httpsUri = "https://foo.example.com:" + h2Port + "/";
|
function testsDone() {
|
||||||
});
|
prefs.clearUserPref("network.http.http3.enabled");
|
||||||
|
prefs.clearUserPref("network.dns.localDomains");
|
||||||
add_task(async function test_fatal_stream_error() {
|
prefs.clearUserPref("network.dns.disableIPv6");
|
||||||
let result = false;
|
prefs.clearUserPref("network.http.http3.alt-svc-mapping-for-testing");
|
||||||
// We need to loop here because we need to wait for AltSvc storage to
|
dump("testDone\n");
|
||||||
// to be started.
|
}
|
||||||
do {
|
|
||||||
// We need to close HTTP2 connections, otherwise our connection pooling
|
|
||||||
// will dispatch the request over already existing HTTP2 connection.
|
|
||||||
Services.obs.notifyObservers(null, "net:prune-all-connections");
|
|
||||||
let chan = makeChan();
|
|
||||||
let listener = new Http3FailedListener();
|
|
||||||
result = await altsvcSetupPromise(chan, listener);
|
|
||||||
} while (result === false);
|
|
||||||
});
|
|
||||||
|
|
||||||
let CheckOnlyHttp2Listener = function() {};
|
|
||||||
|
|
||||||
CheckOnlyHttp2Listener.prototype = {
|
|
||||||
onStartRequest: function testOnStartRequest(request) {},
|
|
||||||
|
|
||||||
onDataAvailable: function testOnDataAvailable(request, stream, off, cnt) {
|
|
||||||
read_stream(stream, cnt);
|
|
||||||
},
|
|
||||||
|
|
||||||
onStopRequest: function testOnStopRequest(request, status) {
|
|
||||||
Assert.equal(status, Cr.NS_OK);
|
|
||||||
let httpVersion = "";
|
|
||||||
try {
|
|
||||||
httpVersion = request.protocolVersion;
|
|
||||||
} catch (e) {}
|
|
||||||
Assert.equal(httpVersion, "h2");
|
|
||||||
this.finish(false);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
add_task(async function test_no_http3_after_error() {
|
|
||||||
let chan = makeChan();
|
|
||||||
let listener = new CheckOnlyHttp2Listener();
|
|
||||||
await altsvcSetupPromise(chan, listener);
|
|
||||||
});
|
|
||||||
|
|
||||||
// also after all connections are closed.
|
|
||||||
add_task(async function test_no_http3_after_error2() {
|
|
||||||
Services.obs.notifyObservers(null, "net:prune-all-connections");
|
|
||||||
let chan = makeChan();
|
|
||||||
let listener = new CheckOnlyHttp2Listener();
|
|
||||||
await altsvcSetupPromise(chan, listener);
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,121 +0,0 @@
|
||||||
/* 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/. */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
let httpsUri;
|
|
||||||
|
|
||||||
registerCleanupFunction(async () => {
|
|
||||||
Services.prefs.clearUserPref("network.http.http3.enabled");
|
|
||||||
Services.prefs.clearUserPref("network.dns.localDomains");
|
|
||||||
Services.prefs.clearUserPref("network.dns.disableIPv6");
|
|
||||||
Services.prefs.clearUserPref(
|
|
||||||
"network.http.http3.alt-svc-mapping-for-testing"
|
|
||||||
);
|
|
||||||
dump("cleanup done\n");
|
|
||||||
});
|
|
||||||
|
|
||||||
function chanPromise(chan, listener) {
|
|
||||||
return new Promise(resolve => {
|
|
||||||
function finish() {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
listener.finish = finish;
|
|
||||||
chan.asyncOpen(listener);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeChan() {
|
|
||||||
let chan = NetUtil.newChannel({
|
|
||||||
uri: httpsUri,
|
|
||||||
loadUsingSystemPrincipal: true,
|
|
||||||
}).QueryInterface(Ci.nsIHttpChannel);
|
|
||||||
chan.loadFlags = Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;
|
|
||||||
return chan;
|
|
||||||
}
|
|
||||||
|
|
||||||
function altsvcSetupPromise(chan, listener) {
|
|
||||||
return new Promise(resolve => {
|
|
||||||
function finish(result) {
|
|
||||||
resolve(result);
|
|
||||||
}
|
|
||||||
listener.finish = finish;
|
|
||||||
chan.asyncOpen(listener);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
add_task(async function test_fatal_error() {
|
|
||||||
let env = Cc["@mozilla.org/process/environment;1"].getService(
|
|
||||||
Ci.nsIEnvironment
|
|
||||||
);
|
|
||||||
|
|
||||||
let h2Port = env.get("MOZHTTP2_PORT");
|
|
||||||
Assert.notEqual(h2Port, null);
|
|
||||||
|
|
||||||
Services.prefs.setBoolPref("network.http.http3.enabled", true);
|
|
||||||
Services.prefs.setCharPref("network.dns.localDomains", "foo.example.com");
|
|
||||||
Services.prefs.setBoolPref("network.dns.disableIPv6", true);
|
|
||||||
// Set AltSvc to point to not existing HTTP3 server on port 443
|
|
||||||
Services.prefs.setCharPref(
|
|
||||||
"network.http.http3.alt-svc-mapping-for-testing",
|
|
||||||
"foo.example.com;h3-27=:443"
|
|
||||||
);
|
|
||||||
|
|
||||||
let certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(
|
|
||||||
Ci.nsIX509CertDB
|
|
||||||
);
|
|
||||||
addCertFromFile(certdb, "http2-ca.pem", "CTu,u,u");
|
|
||||||
|
|
||||||
httpsUri = "https://foo.example.com:" + h2Port + "/";
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_fatal_stream_error() {
|
|
||||||
let result = 1;
|
|
||||||
// We need to loop here because we need to wait for AltSvc storage to
|
|
||||||
// to be started.
|
|
||||||
// We also do not have a way to verify that HTTP3 has been tried, because
|
|
||||||
// the fallback is automatic, so try a couple of times.
|
|
||||||
do {
|
|
||||||
// We need to close HTTP2 connections, otherwise our connection pooling
|
|
||||||
// will dispatch the request over already existing HTTP2 connection.
|
|
||||||
Services.obs.notifyObservers(null, "net:prune-all-connections");
|
|
||||||
let chan = makeChan();
|
|
||||||
let listener = new CheckOnlyHttp2Listener();
|
|
||||||
await altsvcSetupPromise(chan, listener);
|
|
||||||
result++;
|
|
||||||
} while (result < 5);
|
|
||||||
});
|
|
||||||
|
|
||||||
let CheckOnlyHttp2Listener = function() {};
|
|
||||||
|
|
||||||
CheckOnlyHttp2Listener.prototype = {
|
|
||||||
onStartRequest: function testOnStartRequest(request) {},
|
|
||||||
|
|
||||||
onDataAvailable: function testOnDataAvailable(request, stream, off, cnt) {
|
|
||||||
read_stream(stream, cnt);
|
|
||||||
},
|
|
||||||
|
|
||||||
onStopRequest: function testOnStopRequest(request, status) {
|
|
||||||
Assert.equal(status, Cr.NS_OK);
|
|
||||||
let httpVersion = "";
|
|
||||||
try {
|
|
||||||
httpVersion = request.protocolVersion;
|
|
||||||
} catch (e) {}
|
|
||||||
Assert.equal(httpVersion, "h2");
|
|
||||||
this.finish();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
add_task(async function test_no_http3_after_error() {
|
|
||||||
let chan = makeChan();
|
|
||||||
let listener = new CheckOnlyHttp2Listener();
|
|
||||||
await altsvcSetupPromise(chan, listener);
|
|
||||||
});
|
|
||||||
|
|
||||||
// also after all connections are closed.
|
|
||||||
add_task(async function test_no_http3_after_error2() {
|
|
||||||
Services.obs.notifyObservers(null, "net:prune-all-connections");
|
|
||||||
let chan = makeChan();
|
|
||||||
let listener = new CheckOnlyHttp2Listener();
|
|
||||||
await altsvcSetupPromise(chan, listener);
|
|
||||||
});
|
|
|
@ -474,17 +474,10 @@ skip-if = asan || tsan || os == 'win' || os =='android'
|
||||||
skip-if = asan || tsan || os == 'win' || os =='android'
|
skip-if = asan || tsan || os == 'win' || os =='android'
|
||||||
[test_brotli_http.js]
|
[test_brotli_http.js]
|
||||||
[test_altsvc_http3.js]
|
[test_altsvc_http3.js]
|
||||||
skip-if = true
|
skip-if = asan || tsan || os == 'win' || os =='android'
|
||||||
[test_http3_fatal_stream_error.js]
|
[test_http3_fatal_stream_error.js]
|
||||||
skip-if = asan || tsan || os == 'win' || os =='android' || socketprocess_networking
|
skip-if = asan || tsan || os == 'win' || os =='android'
|
||||||
run-sequentially = node server exceptions dont replay well
|
|
||||||
[test_http3_large_post.js]
|
[test_http3_large_post.js]
|
||||||
skip-if = asan || tsan || os == 'win' || os =='android'
|
skip-if = asan || tsan || os == 'win' || os =='android'
|
||||||
[test_http3_error_before_connect.js]
|
|
||||||
skip-if = asan || tsan || os == 'win' || os =='android' || socketprocess_networking
|
|
||||||
run-sequentially = node server exceptions dont replay well
|
|
||||||
[test_http3_server_not_existing.js]
|
|
||||||
skip-if = asan || tsan || os == 'win' || os =='android' || socketprocess_networking
|
|
||||||
run-sequentially = node server exceptions dont replay well
|
|
||||||
[test_cookie_ipv6.js]
|
[test_cookie_ipv6.js]
|
||||||
|
|
||||||
|
|
|
@ -1412,13 +1412,11 @@ class XPCShellTests(object):
|
||||||
msg = process.stdout.readline()
|
msg = process.stdout.readline()
|
||||||
if "server listening" in msg:
|
if "server listening" in msg:
|
||||||
searchObj = re.search(
|
searchObj = re.search(
|
||||||
r"HTTP3 server listening on ports ([0-9]+), ([0-9]+) and ([0-9]+)",
|
r"HTTP3 server listening on ports ([0-9]+) and ([0-9]+)", msg, 0
|
||||||
msg, 0
|
|
||||||
)
|
)
|
||||||
if searchObj:
|
if searchObj:
|
||||||
self.env["MOZHTTP3_PORT"] = searchObj.group(1)
|
self.env["MOZHTTP3_PORT"] = searchObj.group(1)
|
||||||
self.env["MOZHTTP3_PORT_FAILED"] = searchObj.group(2)
|
self.env["MOZHTTP3_PORT_FAILED"] = searchObj.group(2)
|
||||||
self.env["MOZHTTP3_PORT_NO_RESPONSE"] = searchObj.group(3)
|
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
# This occurs if the subprocess couldn't be started
|
# This occurs if the subprocess couldn't be started
|
||||||
self.log.error("Could not run the http3 server: %s" % (str(e)))
|
self.log.error("Could not run the http3 server: %s" % (str(e)))
|
||||||
|
|
Загрузка…
Ссылка в новой задаче