summaryrefslogtreecommitdiffstats
path: root/netwerk/protocol/http/nsHttpConnectionMgr.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
commitda4c7e7ed675c3bf405668739c3012d140856109 (patch)
treecdd868dba063fecba609a1d819de271f0d51b23e /netwerk/protocol/http/nsHttpConnectionMgr.cpp
parentAdding upstream version 125.0.3. (diff)
downloadfirefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz
firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/protocol/http/nsHttpConnectionMgr.cpp')
-rw-r--r--netwerk/protocol/http/nsHttpConnectionMgr.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
index c7c385a42a..dbbd8fe0ca 100644
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -817,10 +817,35 @@ HttpConnectionBase* nsHttpConnectionMgr::FindCoalescableConnection(
for (uint32_t i = 0; i < keyLen; ++i) {
conn = FindCoalescableConnectionByHashKey(ent, ent->mCoalescingKeys[i],
justKidding, aNoHttp2, aNoHttp3);
+
+ auto usableEntry = [&](HttpConnectionBase* conn) {
+ // This is allowed by the spec, but other browsers don't coalesce
+ // so agressively, which surprises developers. See bug 1420777.
+ if (StaticPrefs::network_http_http2_aggressive_coalescing()) {
+ return true;
+ }
+
+ // Make sure that the connection's IP address is one that is in
+ // the set of IP addresses in the entry's DNS response.
+ NetAddr addr;
+ nsresult rv = conn->GetPeerAddr(&addr);
+ if (NS_FAILED(rv)) {
+ // Err on the side of not coalescing
+ return false;
+ }
+ // We don't care about remote port when matching entries.
+ addr.inet.port = 0;
+ return ent->mAddresses.Contains(addr);
+ };
+
if (conn) {
- LOG(("FindCoalescableConnection(%s) match conn %p on dns key %s\n",
- ci->HashKey().get(), conn, ent->mCoalescingKeys[i].get()));
- return conn;
+ LOG(("Found connection with matching hash"));
+ if (usableEntry(conn)) {
+ LOG(("> coalescing"));
+ return conn;
+ } else {
+ LOG(("> not coalescing as remote address not present in DNS records"));
+ }
}
}