Bug 1077312 - Clean up Accept headers on @font-face HTTP requests. r=mcmanus
authorJonathan Kew <jkew@mozilla.com>
Thu, 09 Oct 2014 08:42:02 +0100
changeset 209532 18b961f0fb0067ea9c7a4f94012958376c3733d5
parent 209531 3d2e70bf38135cf6f1293c965cbef901b829c3c7
child 209533 b2cfbc95f7259595a02ae995816b0a878da7cc74
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmcmanus
bugs1077312
milestone35.0a1
Bug 1077312 - Clean up Accept headers on @font-face HTTP requests. r=mcmanus
layout/style/FontFaceSet.cpp
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -434,18 +434,25 @@ FontFaceSet::StartLoad(gfxUserFontEntry*
       aFontFaceSrc->mReferrer->GetSpec(referrerURI);
     LOG(("fontdownloader (%p) download start - font uri: (%s) "
          "referrer uri: (%s)\n",
          fontLoader.get(), fontURI.get(), referrerURI.get()));
   }
 #endif
 
   nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
-  if (httpChannel)
+  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);
+  }
   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);