Bug 1080174 - Do not send Accept-Encoding:gzip,deflate when requesting WOFF or WOFF2 webfonts. r=mcmanus
authorJonathan Kew <jkew@mozilla.com>
Thu, 09 Oct 2014 08:42:51 +0100
changeset 209533 b2cfbc95f7259595a02ae995816b0a878da7cc74
parent 209532 18b961f0fb0067ea9c7a4f94012958376c3733d5
child 209534 5ec8e8f037bb93a347b43b9ac910df91c24fbb07
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmcmanus
bugs1080174
milestone35.0a1
Bug 1080174 - Do not send Accept-Encoding:gzip,deflate when requesting WOFF or WOFF2 webfonts. r=mcmanus
layout/style/FontFaceSet.cpp
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -442,16 +442,23 @@ FontFaceSet::StartLoad(gfxUserFontEntry*
   if (httpChannel) {
     httpChannel->SetReferrer(aFontFaceSrc->mReferrer);
     nsAutoCString accept("application/font-woff;q=0.9,*/*;q=0.8");
     if (Preferences::GetBool(GFX_PREF_WOFF2_ENABLED)) {
       accept.Insert(NS_LITERAL_CSTRING("application/font-woff2;q=1.0,"), 0);
     }
     httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
                                   accept, false);
+    // For WOFF and WOFF2, we should tell servers/proxies/etc NOT to try
+    // and apply additional compression at the content-encoding layer
+    if (aFontFaceSrc->mFormatFlags & (gfxUserFontSet::FLAG_FORMAT_WOFF |
+                                      gfxUserFontSet::FLAG_FORMAT_WOFF2)) {
+      httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept-Encoding"),
+                                    NS_LITERAL_CSTRING("identity"), false);
+    }
   }
   nsCOMPtr<nsISupportsPriority> priorityChannel(do_QueryInterface(channel));
   if (priorityChannel) {
     priorityChannel->AdjustPriority(nsISupportsPriority::PRIORITY_HIGH);
   }
 
   rv = NS_NewStreamLoader(getter_AddRefs(streamLoader), fontLoader);
   NS_ENSURE_SUCCESS(rv, rv);