commit 3ce6095849c00bed4a16f3ced9626541d814e0ba
parent b1edef3cef159670bc464890d055078259bd07ea
Author: Randell Jesup <rjesup@mozilla.com>
Date: Wed, 1 Oct 2025 18:45:55 +0000
Bug 1975014: Add a pref for Compression Dictionaries r=necko-reviewers,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D255666
Diffstat:
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
@@ -15688,6 +15688,12 @@
value: false
mirror: always
+# Enable HTTP Compression Dictionary support
+- name: network.http.dictionaries.enable
+ type: RelaxedAtomicBool
+ value: true
+ mirror: always
+
#---------------------------------------------------------------------------
# Prefs starting with "nglayout."
#---------------------------------------------------------------------------
diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -5935,7 +5935,9 @@ nsresult DoAddCacheEntryHeaders(nsHttpChannel* self, nsICacheEntry* entry,
if (NS_FAILED(rv)) return rv;
// If this is being marked as a dictionary, add it to the list
- self->ParseDictionary(entry, responseHead);
+ if (StaticPrefs::network_http_dictionaries_enable() && self->IsHTTPS()) {
+ self->ParseDictionary(entry, responseHead);
+ }
// Indicate we have successfully finished setting metadata on the cache entry.
rv = entry->MetaDataReady();
diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -665,9 +665,8 @@ nsresult nsHttpHandler::AddAcceptAndDictionaryHeaders(
// XXX This would require that AddAcceptAndDictionaryHeaders be effectively
// async, perhaps by passing a lambda to call AddAcceptAndDictionaryHeaders
// and then unblock the request
- aDict =
- mDictionaryCache ? mDictionaryCache->GetDictionaryFor(aURI) : nullptr;
- if (aDict) {
+ if (StaticPrefs::network_http_dictionaries_enable() &&
+ (aDict = mDictionaryCache->GetDictionaryFor(aURI))) {
rv = aRequest->SetHeader(nsHttp::Accept_Encoding,
mDictionaryAcceptEncodings, false,
nsHttpHeaderArray::eVarietyRequestOverride);