summaryrefslogtreecommitdiffstats
path: root/netwerk/protocol/http
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /netwerk/protocol/http
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/protocol/http')
-rw-r--r--netwerk/protocol/http/ConnectionEntry.cpp3
-rw-r--r--netwerk/protocol/http/Http3WebTransportSession.cpp10
-rw-r--r--netwerk/protocol/http/HttpBaseChannel.cpp15
-rw-r--r--netwerk/protocol/http/HttpBaseChannel.h8
-rw-r--r--netwerk/protocol/http/HttpChannelChild.cpp8
-rw-r--r--netwerk/protocol/http/HttpChannelChild.h3
-rw-r--r--netwerk/protocol/http/NullHttpChannel.cpp10
-rw-r--r--netwerk/protocol/http/ObliviousHttpChannel.cpp10
-rw-r--r--netwerk/protocol/http/nsHttpChannel.cpp135
-rw-r--r--netwerk/protocol/http/nsHttpChannel.h5
-rw-r--r--netwerk/protocol/http/nsHttpConnection.cpp8
-rw-r--r--netwerk/protocol/http/nsHttpConnectionMgr.cpp36
-rw-r--r--netwerk/protocol/http/nsHttpHandler.cpp20
-rw-r--r--netwerk/protocol/http/nsHttpTransaction.cpp24
-rw-r--r--netwerk/protocol/http/nsHttpTransaction.h6
-rw-r--r--netwerk/protocol/http/nsIHttpChannel.idl8
-rw-r--r--netwerk/protocol/http/nsIHttpChannelInternal.idl2
17 files changed, 238 insertions, 73 deletions
diff --git a/netwerk/protocol/http/ConnectionEntry.cpp b/netwerk/protocol/http/ConnectionEntry.cpp
index dc0dfd103c..36ebba5ec3 100644
--- a/netwerk/protocol/http/ConnectionEntry.cpp
+++ b/netwerk/protocol/http/ConnectionEntry.cpp
@@ -509,6 +509,9 @@ void ConnectionEntry::VerifyTraffic() {
mActiveConns.RemoveElementAt(index);
gHttpHandler->ConnMgr()->DecrementActiveConnCount(conn);
mPendingConns.AppendElement(conn);
+ // After DontReuse(), the connection will be closed after the last
+ // transition is done.
+ conn->DontReuse();
LOG(("Move active connection to pending list [conn=%p]\n",
conn.get()));
}
diff --git a/netwerk/protocol/http/Http3WebTransportSession.cpp b/netwerk/protocol/http/Http3WebTransportSession.cpp
index 9ef4da70c0..cee1fd75fd 100644
--- a/netwerk/protocol/http/Http3WebTransportSession.cpp
+++ b/netwerk/protocol/http/Http3WebTransportSession.cpp
@@ -447,7 +447,10 @@ Http3WebTransportSession::OnIncomingWebTransportStream(
return nullptr;
}
- mListener->OnIncomingStreamAvailableInternal(stream);
+ if (nsCOMPtr<WebTransportSessionEventListenerInternal> listener =
+ do_QueryInterface(mListener)) {
+ listener->OnIncomingStreamAvailableInternal(stream);
+ }
return stream.forget();
}
@@ -470,7 +473,10 @@ void Http3WebTransportSession::OnDatagramReceived(nsTArray<uint8_t>&& aData) {
return;
}
- mListener->OnDatagramReceivedInternal(std::move(aData));
+ if (nsCOMPtr<WebTransportSessionEventListenerInternal> listener =
+ do_QueryInterface(mListener)) {
+ listener->OnDatagramReceivedInternal(std::move(aData));
+ }
}
void Http3WebTransportSession::GetMaxDatagramSize() {
diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp
index ff88b02753..8483bb6144 100644
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -1319,8 +1319,6 @@ void HttpBaseChannel::ExplicitSetUploadStreamLength(
return;
}
- // SetRequestHeader propagates headers to chrome if HttpChannelChild
- MOZ_ASSERT(!LoadWasOpened());
nsAutoCString contentLengthStr;
contentLengthStr.AppendInt(aContentLength);
SetRequestHeader(header, contentLengthStr, false);
@@ -2298,6 +2296,19 @@ HttpBaseChannel::UpgradeToSecure() {
}
NS_IMETHODIMP
+HttpBaseChannel::GetRequestObserversCalled(bool* aCalled) {
+ NS_ENSURE_ARG_POINTER(aCalled);
+ *aCalled = LoadRequestObserversCalled();
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+HttpBaseChannel::SetRequestObserversCalled(bool aCalled) {
+ StoreRequestObserversCalled(aCalled);
+ return NS_OK;
+}
+
+NS_IMETHODIMP
HttpBaseChannel::GetRequestContextID(uint64_t* aRCID) {
NS_ENSURE_ARG_POINTER(aRCID);
*aRCID = mRequestContextID;
diff --git a/netwerk/protocol/http/HttpBaseChannel.h b/netwerk/protocol/http/HttpBaseChannel.h
index d6d693212b..3a2c6192d1 100644
--- a/netwerk/protocol/http/HttpBaseChannel.h
+++ b/netwerk/protocol/http/HttpBaseChannel.h
@@ -228,6 +228,8 @@ class HttpBaseChannel : public nsHashPropertyBag,
NS_IMETHOD GetRequestSucceeded(bool* aValue) override;
NS_IMETHOD RedirectTo(nsIURI* newURI) override;
NS_IMETHOD UpgradeToSecure() override;
+ NS_IMETHOD GetRequestObserversCalled(bool* aCalled) override;
+ NS_IMETHOD SetRequestObserversCalled(bool aCalled) override;
NS_IMETHOD GetRequestContextID(uint64_t* aRCID) override;
NS_IMETHOD GetTransferSize(uint64_t* aTransferSize) override;
NS_IMETHOD GetRequestSize(uint64_t* aRequestSize) override;
@@ -690,6 +692,9 @@ class HttpBaseChannel : public nsHashPropertyBag,
void SetChannelBlockedByOpaqueResponse();
bool Http3Allowed() const;
+ virtual void ExplicitSetUploadStreamLength(uint64_t aContentLength,
+ bool aSetContentLengthHeader);
+
friend class OpaqueResponseBlocker;
friend class PrivateBrowsingChannel<HttpBaseChannel>;
friend class InterceptFailedOnStop;
@@ -721,9 +726,6 @@ class HttpBaseChannel : public nsHashPropertyBag,
// Proxy release all members above on main thread.
void ReleaseMainThreadOnlyReferences();
- void ExplicitSetUploadStreamLength(uint64_t aContentLength,
- bool aSetContentLengthHeader);
-
void MaybeResumeAsyncOpen();
protected:
diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp
index 8b581b070e..97c80b046a 100644
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -3418,4 +3418,12 @@ NS_IMETHODIMP HttpChannelChild::SetWebTransportSessionEventListener(
return NS_OK;
}
+void HttpChannelChild::ExplicitSetUploadStreamLength(
+ uint64_t aContentLength, bool aSetContentLengthHeader) {
+ // SetRequestHeader propagates headers to chrome if HttpChannelChild
+ MOZ_ASSERT(!LoadWasOpened());
+ HttpBaseChannel::ExplicitSetUploadStreamLength(aContentLength,
+ aSetContentLengthHeader);
+}
+
} // namespace mozilla::net
diff --git a/netwerk/protocol/http/HttpChannelChild.h b/netwerk/protocol/http/HttpChannelChild.h
index 8cfc820a23..190b195aaa 100644
--- a/netwerk/protocol/http/HttpChannelChild.h
+++ b/netwerk/protocol/http/HttpChannelChild.h
@@ -187,6 +187,9 @@ class HttpChannelChild final : public PHttpChannelChild,
const nsAString& aURL,
const nsAString& aContentType) override;
+ virtual void ExplicitSetUploadStreamLength(
+ uint64_t aContentLength, bool aSetContentLengthHeader) override;
+
private:
// We want to handle failure result of AsyncOpen, hence AsyncOpen calls the
// Internal method
diff --git a/netwerk/protocol/http/NullHttpChannel.cpp b/netwerk/protocol/http/NullHttpChannel.cpp
index eae11441af..8916c8a48e 100644
--- a/netwerk/protocol/http/NullHttpChannel.cpp
+++ b/netwerk/protocol/http/NullHttpChannel.cpp
@@ -247,6 +247,16 @@ NS_IMETHODIMP
NullHttpChannel::UpgradeToSecure() { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHODIMP
+NullHttpChannel::GetRequestObserversCalled(bool* aCalled) {
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+NullHttpChannel::SetRequestObserversCalled(bool aCalled) {
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
NullHttpChannel::GetRequestContextID(uint64_t* _retval) {
return NS_ERROR_NOT_IMPLEMENTED;
}
diff --git a/netwerk/protocol/http/ObliviousHttpChannel.cpp b/netwerk/protocol/http/ObliviousHttpChannel.cpp
index 1b4449f004..99b1def6d5 100644
--- a/netwerk/protocol/http/ObliviousHttpChannel.cpp
+++ b/netwerk/protocol/http/ObliviousHttpChannel.cpp
@@ -351,6 +351,16 @@ ObliviousHttpChannel::UpgradeToSecure() {
}
NS_IMETHODIMP
+ObliviousHttpChannel::GetRequestObserversCalled(bool* aCalled) {
+ return mInnerChannel->GetRequestObserversCalled(aCalled);
+}
+
+NS_IMETHODIMP
+ObliviousHttpChannel::SetRequestObserversCalled(bool aCalled) {
+ return mInnerChannel->SetRequestObserversCalled(aCalled);
+}
+
+NS_IMETHODIMP
ObliviousHttpChannel::GetRequestContextID(uint64_t* _retval) {
return mInnerChannel->GetRequestContextID(_retval);
}
diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp
index 4428b72426..c5e6deb241 100644
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -637,6 +637,32 @@ nsresult nsHttpChannel::OnBeforeConnect() {
return MaybeUseHTTPSRRForUpgrade(shouldUpgrade, NS_OK);
}
+// Returns true if the network connectivity checker indicated
+// that HTTPS records can be resolved on this network - false otherwise.
+// When TRR is enabled, we always return true, as resolving HTTPS
+// records don't depend on the network.
+static bool canUseHTTPSRRonNetwork() {
+ if (nsCOMPtr<nsIDNSService> dns = mozilla::components::DNS::Service()) {
+ nsIDNSService::ResolverMode mode;
+ // If the browser is currently using TRR/DoH, then it can
+ // definitely resolve HTTPS records.
+ if (NS_SUCCEEDED(dns->GetCurrentTrrMode(&mode)) &&
+ (mode == nsIDNSService::MODE_TRRFIRST ||
+ mode == nsIDNSService::MODE_TRRONLY)) {
+ return true;
+ }
+ }
+ if (RefPtr<NetworkConnectivityService> ncs =
+ NetworkConnectivityService::GetSingleton()) {
+ nsINetworkConnectivityService::ConnectivityState state;
+ if (NS_SUCCEEDED(ncs->GetDNS_HTTPS(&state)) &&
+ state == nsINetworkConnectivityService::NOT_AVAILABLE) {
+ return false;
+ }
+ }
+ return true;
+}
+
nsresult nsHttpChannel::MaybeUseHTTPSRRForUpgrade(bool aShouldUpgrade,
nsresult aStatus) {
if (NS_FAILED(aStatus)) {
@@ -657,6 +683,13 @@ nsresult nsHttpChannel::MaybeUseHTTPSRRForUpgrade(bool aShouldUpgrade,
return true;
}
+ // If the network connectivity checker indicates the network is
+ // blocking HTTPS requests, then we should skip them so we don't
+ // needlessly wait for a timeout.
+ if (!canUseHTTPSRRonNetwork()) {
+ return true;
+ }
+
nsAutoCString uriHost;
mURI->GetAsciiHost(uriHost);
@@ -1022,11 +1055,22 @@ nsresult nsHttpChannel::DoConnectActual(
LOG(("nsHttpChannel::DoConnectActual [this=%p, aTransWithStickyConn=%p]\n",
this, aTransWithStickyConn));
- nsresult rv = SetupTransaction();
+ nsresult rv = SetupChannelForTransaction();
if (NS_FAILED(rv)) {
return rv;
}
+ return DispatchTransaction(aTransWithStickyConn);
+}
+
+nsresult nsHttpChannel::DispatchTransaction(
+ HttpTransactionShell* aTransWithStickyConn) {
+ LOG(("nsHttpChannel::DispatchTransaction [this=%p, aTransWithStickyConn=%p]",
+ this, aTransWithStickyConn));
+ nsresult rv = InitTransaction();
+ if (NS_FAILED(rv)) {
+ return rv;
+ }
if (aTransWithStickyConn) {
rv = gHttpHandler->InitiateTransactionWithStickyConn(
mTransaction, mPriority, aTransWithStickyConn);
@@ -1212,10 +1256,11 @@ void nsHttpChannel::HandleAsyncNotModified() {
if (mLoadGroup) mLoadGroup->RemoveRequest(this, nullptr, mStatus);
}
-nsresult nsHttpChannel::SetupTransaction() {
- LOG(("nsHttpChannel::SetupTransaction [this=%p, cos=%lu, inc=%d prio=%d]\n",
- this, mClassOfService.Flags(), mClassOfService.Incremental(),
- mPriority));
+nsresult nsHttpChannel::SetupChannelForTransaction() {
+ LOG((
+ "nsHttpChannel::SetupChannelForTransaction [this=%p, cos=%lu, inc=%d "
+ "prio=%d]\n",
+ this, mClassOfService.Flags(), mClassOfService.Incremental(), mPriority));
NS_ENSURE_TRUE(!mTransaction, NS_ERROR_ALREADY_INITIALIZED);
@@ -1340,24 +1385,37 @@ nsresult nsHttpChannel::SetupTransaction() {
// We need to send 'Pragma:no-cache' to inhibit proxy caching even if
// no proxy is configured since we might be talking with a transparent
// proxy, i.e. one that operates at the network level. See bug #14772.
- rv = mRequestHead.SetHeaderOnce(nsHttp::Pragma, "no-cache", true);
- MOZ_ASSERT(NS_SUCCEEDED(rv));
+ // But we should not touch Pragma if Cache-Control is already set
+ // (https://fetch.spec.whatwg.org/#ref-for-concept-request-cache-mode%E2%91%A3)
+ if (!mRequestHead.HasHeader(nsHttp::Pragma)) {
+ rv = mRequestHead.SetHeaderOnce(nsHttp::Pragma, "no-cache", true);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
+ }
// If we're configured to speak HTTP/1.1 then also send 'Cache-control:
- // no-cache'
- if (mRequestHead.Version() >= HttpVersion::v1_1) {
+ // no-cache'. But likewise don't touch Cache-Control if it's already set.
+ if (mRequestHead.Version() >= HttpVersion::v1_1 &&
+ !mRequestHead.HasHeader(nsHttp::Cache_Control)) {
rv = mRequestHead.SetHeaderOnce(nsHttp::Cache_Control, "no-cache", true);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
- } else if ((mLoadFlags & VALIDATE_ALWAYS) && !LoadCacheEntryIsWriteOnly()) {
+ } else if (mLoadFlags & VALIDATE_ALWAYS) {
// We need to send 'Cache-Control: max-age=0' to force each cache along
// the path to the origin server to revalidate its own entry, if any,
// with the next cache or server. See bug #84847.
//
// If we're configured to speak HTTP/1.0 then just send 'Pragma: no-cache'
+ //
+ // But don't send the headers if they're already set:
+ // https://fetch.spec.whatwg.org/#ref-for-concept-request-cache-mode%E2%91%A2
if (mRequestHead.Version() >= HttpVersion::v1_1) {
- rv = mRequestHead.SetHeaderOnce(nsHttp::Cache_Control, "max-age=0", true);
+ if (!mRequestHead.HasHeader(nsHttp::Cache_Control)) {
+ rv = mRequestHead.SetHeaderOnce(nsHttp::Cache_Control, "max-age=0",
+ true);
+ }
} else {
- rv = mRequestHead.SetHeaderOnce(nsHttp::Pragma, "no-cache", true);
+ if (!mRequestHead.HasHeader(nsHttp::Pragma)) {
+ rv = mRequestHead.SetHeaderOnce(nsHttp::Pragma, "no-cache", true);
+ }
}
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
@@ -1395,6 +1453,30 @@ nsresult nsHttpChannel::SetupTransaction() {
}
}
+ // See bug #466080. Transfer LOAD_ANONYMOUS flag to socket-layer.
+ if (mLoadFlags & LOAD_ANONYMOUS) mCaps |= NS_HTTP_LOAD_ANONYMOUS;
+
+ if (LoadTimingEnabled()) mCaps |= NS_HTTP_TIMING_ENABLED;
+
+ if (mUpgradeProtocolCallback) {
+ rv = mRequestHead.SetHeader(nsHttp::Upgrade, mUpgradeProtocol, false);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
+ rv = mRequestHead.SetHeaderOnce(nsHttp::Connection, nsHttp::Upgrade.get(),
+ true);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
+ mCaps |= NS_HTTP_STICKY_CONNECTION;
+ mCaps &= ~NS_HTTP_ALLOW_KEEPALIVE;
+ }
+
+ if (mWebTransportSessionEventListener) {
+ mCaps |= NS_HTTP_STICKY_CONNECTION;
+ }
+
+ return NS_OK;
+}
+
+nsresult nsHttpChannel::InitTransaction() {
+ nsresult rv;
// create wrapper for this channel's notification callbacks
nsCOMPtr<nsIInterfaceRequestor> callbacks;
NS_NewNotificationCallbacksAggregation(mCallbacks, mLoadGroup,
@@ -1445,25 +1527,6 @@ nsresult nsHttpChannel::SetupTransaction() {
// nsIHttpActivityObserver.
gHttpHandler->AddHttpChannel(mChannelId, ToSupports(this));
- // See bug #466080. Transfer LOAD_ANONYMOUS flag to socket-layer.
- if (mLoadFlags & LOAD_ANONYMOUS) mCaps |= NS_HTTP_LOAD_ANONYMOUS;
-
- if (LoadTimingEnabled()) mCaps |= NS_HTTP_TIMING_ENABLED;
-
- if (mUpgradeProtocolCallback) {
- rv = mRequestHead.SetHeader(nsHttp::Upgrade, mUpgradeProtocol, false);
- MOZ_ASSERT(NS_SUCCEEDED(rv));
- rv = mRequestHead.SetHeaderOnce(nsHttp::Connection, nsHttp::Upgrade.get(),
- true);
- MOZ_ASSERT(NS_SUCCEEDED(rv));
- mCaps |= NS_HTTP_STICKY_CONNECTION;
- mCaps &= ~NS_HTTP_ALLOW_KEEPALIVE;
- }
-
- if (mWebTransportSessionEventListener) {
- mCaps |= NS_HTTP_STICKY_CONNECTION;
- }
-
nsCOMPtr<nsIHttpPushListener> pushListener;
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
NS_GET_IID(nsIHttpPushListener),
@@ -6566,7 +6629,7 @@ nsresult nsHttpChannel::BeginConnect() {
!(mLoadInfo->TriggeringPrincipal()->IsSystemPrincipal() &&
mLoadInfo->GetExternalContentPolicyType() !=
ExtContentPolicy::TYPE_DOCUMENT) &&
- !mConnectionInfo->UsingConnect();
+ !mConnectionInfo->UsingConnect() && canUseHTTPSRRonNetwork();
if (!httpsRRAllowed) {
mCaps |= NS_HTTP_DISALLOW_HTTPS_RR;
}
@@ -6611,8 +6674,10 @@ nsresult nsHttpChannel::BeginConnect() {
Unused << gHttpHandler->AddConnectionHeader(&mRequestHead, mCaps);
if (!LoadIsTRRServiceChannel() &&
- (mLoadFlags & VALIDATE_ALWAYS ||
- BYPASS_LOCAL_CACHE(mLoadFlags, LoadPreferCacheLoadOverBypass()))) {
+ ((mLoadFlags & LOAD_FRESH_CONNECTION) ||
+ (!StaticPrefs::network_dns_only_refresh_on_fresh_connection() &&
+ (mLoadFlags & VALIDATE_ALWAYS ||
+ BYPASS_LOCAL_CACHE(mLoadFlags, LoadPreferCacheLoadOverBypass()))))) {
mCaps |= NS_HTTP_REFRESH_DNS;
}
@@ -6753,7 +6818,7 @@ nsresult nsHttpChannel::MaybeStartDNSPrefetch() {
}
if (gHttpHandler->UseHTTPSRRAsAltSvcEnabled() && !mHTTPSSVCRecord &&
- !(mCaps & NS_HTTP_DISALLOW_HTTPS_RR)) {
+ !(mCaps & NS_HTTP_DISALLOW_HTTPS_RR) && canUseHTTPSRRonNetwork()) {
MOZ_ASSERT(!mHTTPSSVCRecord);
OriginAttributes originAttributes;
diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h
index e2fb5abde9..78dac11a4d 100644
--- a/netwerk/protocol/http/nsHttpChannel.h
+++ b/netwerk/protocol/http/nsHttpChannel.h
@@ -335,7 +335,10 @@ class nsHttpChannel final : public HttpBaseChannel,
void OnHTTPSRRAvailable(nsIDNSHTTPSSVCRecord* aRecord);
[[nodiscard]] nsresult Connect();
void SpeculativeConnect();
- [[nodiscard]] nsresult SetupTransaction();
+ [[nodiscard]] nsresult SetupChannelForTransaction();
+ [[nodiscard]] nsresult InitTransaction();
+ [[nodiscard]] nsresult DispatchTransaction(
+ HttpTransactionShell* aTransWithStickyConn);
[[nodiscard]] nsresult CallOnStartRequest();
[[nodiscard]] nsresult ProcessResponse();
void AsyncContinueProcessResponse();
diff --git a/netwerk/protocol/http/nsHttpConnection.cpp b/netwerk/protocol/http/nsHttpConnection.cpp
index cd41cd65bc..54e1d25557 100644
--- a/netwerk/protocol/http/nsHttpConnection.cpp
+++ b/netwerk/protocol/http/nsHttpConnection.cpp
@@ -895,14 +895,6 @@ bool nsHttpConnection::IsAlive() {
nsresult rv = mSocketTransport->IsAlive(&alive);
if (NS_FAILED(rv)) alive = false;
-// #define TEST_RESTART_LOGIC
-#ifdef TEST_RESTART_LOGIC
- if (!alive) {
- LOG(("pretending socket is still alive to test restart logic\n"));
- alive = true;
- }
-#endif
-
return alive;
}
diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
index dbbd8fe0ca..28e2f3f07c 100644
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -62,16 +62,23 @@ struct UrlMarker {
}
static void StreamJSONMarkerData(
mozilla::baseprofiler::SpliceableJSONWriter& aWriter,
- const mozilla::ProfilerString8View& aURL) {
+ const mozilla::ProfilerString8View& aURL, const TimeDuration& aDuration,
+ uint64_t aChannelId) {
if (aURL.Length() != 0) {
aWriter.StringProperty("url", aURL);
}
+ if (!aDuration.IsZero()) {
+ aWriter.DoubleProperty("duration", aDuration.ToMilliseconds());
+ }
+ aWriter.IntProperty("channelId", static_cast<int64_t>(aChannelId));
}
static MarkerSchema MarkerTypeDisplay() {
using MS = MarkerSchema;
MS schema(MS::Location::MarkerChart, MS::Location::MarkerTable);
schema.SetTableLabel("{marker.name} - {marker.data.url}");
- schema.AddKeyFormat("url", MS::Format::Url);
+ schema.AddKeyFormatSearchable("url", MS::Format::Url,
+ MS::Searchable::Searchable);
+ schema.AddKeyLabelFormat("duration", "Duration", MS::Format::Duration);
return schema;
}
};
@@ -505,9 +512,10 @@ nsresult nsHttpConnectionMgr::SpeculativeConnect(
return NS_OK;
}
- nsCString url = ci->EndToEndSSL() ? "https://"_ns : "http://"_ns;
+ nsAutoCString url(ci->EndToEndSSL() ? "https://"_ns : "http://"_ns);
url += ci->GetOrigin();
- PROFILER_MARKER("SpeculativeConnect", NETWORK, {}, UrlMarker, url);
+ PROFILER_MARKER("SpeculativeConnect", NETWORK, {}, UrlMarker, url,
+ TimeDuration::Zero(), 0);
RefPtr<SpeculativeConnectArgs> args = new SpeculativeConnectArgs();
@@ -800,6 +808,11 @@ HttpConnectionBase* nsHttpConnectionMgr::FindCoalescableConnection(
MOZ_ASSERT(ent->mConnInfo);
nsHttpConnectionInfo* ci = ent->mConnInfo;
LOG(("FindCoalescableConnection %s\n", ci->HashKey().get()));
+
+ if (ci->GetWebTransport()) {
+ LOG(("Don't coalesce a WebTransport conn "));
+ return nullptr;
+ }
// First try and look it up by origin frame
nsCString newKey;
BuildOriginFrameHashKey(newKey, ci, ci->GetOrigin(), ci->OriginPort());
@@ -1649,9 +1662,9 @@ nsresult nsHttpConnectionMgr::DispatchTransaction(ConnectionEntry* ent,
trans->CancelPacing(NS_OK);
TimeStamp now = TimeStamp::Now();
+ TimeDuration elapsed = now - trans->GetPendingTime();
auto recordPendingTimeForHTTPSRR = [&](nsCString& aKey) {
uint32_t stage = trans->HTTPSSVCReceivedStage();
- TimeDuration elapsed = now - trans->GetPendingTime();
if (HTTPS_RR_IS_USED(stage)) {
glean::networking::transaction_wait_time_https_rr.AccumulateRawDuration(
elapsed);
@@ -1659,10 +1672,16 @@ nsresult nsHttpConnectionMgr::DispatchTransaction(ConnectionEntry* ent,
} else {
glean::networking::transaction_wait_time.AccumulateRawDuration(elapsed);
}
- PerfStats::RecordMeasurement(PerfStats::Metric::HttpTransactionWaitTime,
- elapsed);
};
+ PerfStats::RecordMeasurement(PerfStats::Metric::HttpTransactionWaitTime,
+ elapsed);
+
+ PROFILER_MARKER(
+ "DispatchTransaction", NETWORK,
+ MarkerOptions(MarkerTiming::Interval(trans->GetPendingTime(), now)),
+ UrlMarker, trans->GetUrl(), elapsed, trans->ChannelId());
+
nsAutoCString httpVersionkey("h1"_ns);
if (conn->UsingSpdy() || conn->UsingHttp3()) {
LOG(
@@ -1770,6 +1789,9 @@ nsresult nsHttpConnectionMgr::ProcessNewTransaction(nsHttpTransaction* trans) {
trans->SetPendingTime();
+ PROFILER_MARKER("ProcessNewTransaction", NETWORK, {}, UrlMarker,
+ trans->GetUrl(), TimeDuration::Zero(), trans->ChannelId());
+
RefPtr<Http2PushedStreamWrapper> pushedStreamWrapper =
trans->GetPushedStream();
if (pushedStreamWrapper) {
diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp
index b6440c88b5..d0aebdf965 100644
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -2204,12 +2204,8 @@ nsresult nsHttpHandler::SpeculativeConnectInternal(
originAttributes = std::move(aOriginAttributes.ref());
} else if (aPrincipal) {
originAttributes = aPrincipal->OriginAttributesRef();
- StoragePrincipalHelper::UpdateOriginAttributesForNetworkState(
- aURI, originAttributes);
} else if (loadContext) {
loadContext->GetOriginAttributes(originAttributes);
- StoragePrincipalHelper::UpdateOriginAttributesForNetworkState(
- aURI, originAttributes);
}
nsCOMPtr<nsIURI> clone;
@@ -2222,6 +2218,15 @@ nsresult nsHttpHandler::SpeculativeConnectInternal(
}
}
+ if (!aOriginAttributes) {
+ // We must update the originAttributes with the network state first party
+ // domain **after** we upgrade aURI to https.
+ // Otherwise the speculative connection will be keyed by a http URL
+ // and end up not being used.
+ StoragePrincipalHelper::UpdateOriginAttributesForNetworkState(
+ aURI, originAttributes);
+ }
+
nsAutoCString scheme;
nsresult rv = aURI->GetScheme(scheme);
if (NS_FAILED(rv)) return rv;
@@ -2748,12 +2753,15 @@ bool nsHttpHandler::UseHTTPSRRAsAltSvcEnabled() const {
}
bool nsHttpHandler::EchConfigEnabled(bool aIsHttp3) const {
+ if (mParentalControlEnabled) {
+ return false;
+ }
+
if (!aIsHttp3) {
return StaticPrefs::network_dns_echconfig_enabled();
}
- return StaticPrefs::network_dns_echconfig_enabled() &&
- StaticPrefs::network_dns_http3_echconfig_enabled();
+ return StaticPrefs::network_dns_http3_echconfig_enabled();
}
bool nsHttpHandler::FallbackToOriginIfConfigsAreECHAndAllFailed() const {
diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp
index 24ef50fb85..545dd5a142 100644
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
@@ -398,11 +398,16 @@ nsresult nsHttpTransaction::Init(
}
RefPtr<nsHttpChannel> httpChannel = do_QueryObject(eventsink);
- RefPtr<WebTransportSessionEventListener> listener =
- httpChannel ? httpChannel->GetWebTransportSessionEventListener()
- : nullptr;
- if (listener) {
- mWebTransportSessionEventListener = std::move(listener);
+ if (httpChannel) {
+ RefPtr<WebTransportSessionEventListener> listener =
+ httpChannel->GetWebTransportSessionEventListener();
+ if (listener) {
+ mWebTransportSessionEventListener = std::move(listener);
+ }
+ nsCOMPtr<nsIURI> uri;
+ if (NS_SUCCEEDED(httpChannel->GetURI(getter_AddRefs(uri)))) {
+ mUrl = uri->GetSpecOrDefault();
+ }
}
return NS_OK;
@@ -2198,8 +2203,9 @@ bool nsHttpTransaction::HandleWebTransportResponse(uint16_t aStatus) {
webTransportListener = mWebTransportSessionEventListener;
mWebTransportSessionEventListener = nullptr;
}
- if (webTransportListener) {
- webTransportListener->OnSessionReadyInternal(wtSession);
+ if (nsCOMPtr<WebTransportSessionEventListenerInternal> listener =
+ do_QueryInterface(webTransportListener)) {
+ listener->OnSessionReadyInternal(wtSession);
wtSession->SetWebTransportSessionEventListener(webTransportListener);
}
@@ -3289,7 +3295,9 @@ nsresult nsHttpTransaction::OnHTTPSRRAvailable(
RefPtr<nsHttpConnectionInfo> newInfo =
mConnInfo->CloneAndAdoptHTTPSSVCRecord(svcbRecord);
- bool needFastFallback = newInfo->IsHttp3();
+ // Don't fallback until we support WebTransport over HTTP/2.
+ // TODO: implement fallback in bug 1874102.
+ bool needFastFallback = newInfo->IsHttp3() && !newInfo->GetWebTransport();
bool foundInPendingQ = gHttpHandler->ConnMgr()->RemoveTransFromConnEntry(
this, mHashKeyOfConnectionEntry);
diff --git a/netwerk/protocol/http/nsHttpTransaction.h b/netwerk/protocol/http/nsHttpTransaction.h
index 5256de4cf2..dd019e00e8 100644
--- a/netwerk/protocol/http/nsHttpTransaction.h
+++ b/netwerk/protocol/http/nsHttpTransaction.h
@@ -196,6 +196,10 @@ class nsHttpTransaction final : public nsAHttpTransaction,
bool IsForWebTransport() { return mIsForWebTransport; }
+ nsAutoCString GetUrl() { return mUrl; }
+
+ uint64_t ChannelId() { return mChannelId; }
+
private:
friend class DeleteHttpTransaction;
virtual ~nsHttpTransaction();
@@ -593,6 +597,8 @@ class nsHttpTransaction final : public nsAHttpTransaction,
nsCString mHashKeyOfConnectionEntry;
nsCOMPtr<WebTransportSessionEventListener> mWebTransportSessionEventListener;
+
+ nsAutoCString mUrl;
};
} // namespace mozilla::net
diff --git a/netwerk/protocol/http/nsIHttpChannel.idl b/netwerk/protocol/http/nsIHttpChannel.idl
index 1bd7aeba37..a8372ba080 100644
--- a/netwerk/protocol/http/nsIHttpChannel.idl
+++ b/netwerk/protocol/http/nsIHttpChannel.idl
@@ -494,4 +494,12 @@ interface nsIHttpChannel : nsIIdentChannel
[must_use] attribute AString classicScriptHintCharset;
[must_use] attribute AString documentCharacterSet;
+
+ /**
+ * Update the requestObserversCalled boolean flag.
+ *
+ * Used by WebDriver BiDi network interception to modify properties of the
+ * request such as `method` or `body` as late as possible.
+ */
+ [must_use] attribute boolean requestObserversCalled;
};
diff --git a/netwerk/protocol/http/nsIHttpChannelInternal.idl b/netwerk/protocol/http/nsIHttpChannelInternal.idl
index 64f41be28b..620718f4bb 100644
--- a/netwerk/protocol/http/nsIHttpChannelInternal.idl
+++ b/netwerk/protocol/http/nsIHttpChannelInternal.idl
@@ -56,7 +56,7 @@ interface nsIHttpUpgradeListener : nsISupports
[must_use] void onUpgradeFailed(in nsresult aErrorCode);
- void onWebSocketConnectionAvailable(in WebSocketConnectionBase aConnection);
+ [noscript] void onWebSocketConnectionAvailable(in WebSocketConnectionBase aConnection);
};
/**