Bug 1596000 - Avoid double pre-flight OPTIONS request when not necessary. r=Neil a=jorgk
authorBen Bucksch <ben.bucksch@beonex.com>
Wed, 13 Nov 2019 18:13:02 +0100
changeset 37282 db6162333c542d956ba8f43f9d94a6abfdf10686
parent 37281 216e79bcfb3ffdb15169f9445b2fe2de00926e3e
child 37283 f2f7e2432a04fe3a25bf50da78b3fcd08381d129
push id395
push userclokep@gmail.com
push dateMon, 02 Dec 2019 19:38:57 +0000
reviewersNeil, jorgk
bugs1596000
Bug 1596000 - Avoid double pre-flight OPTIONS request when not necessary. r=Neil a=jorgk Even though they could theoretically on different hostnames, they are in reality both on the same host, so avoid the second OPTIONS request, if it's on the same host.
mail/components/accountcreation/content/emailWizard.js
--- a/mail/components/accountcreation/content/emailWizard.js
+++ b/mail/components/accountcreation/content/emailWizard.js
@@ -277,24 +277,26 @@ EmailConfigWizard.prototype = {
     _show("result_area");
     _hide("manual-edit_area");
 
     this.switchToMode("start");
     e("realname").select();
     window.sizeToContent();
 
     // In a new profile, the first request to live.thunderbird.net
-    // is much slower because of one-time overheads.
+    // is much slower because of one-time overheads like DNS and OCSP.
     // Let's create some dummy requests to prime the connections.
-    fetch(Services.prefs.getCharPref("mailnews.auto_config_url"), {
-      method: "OPTIONS",
-    });
-    fetch(Services.prefs.getCharPref("mailnews.auto_config.addons_url"), {
-      method: "OPTIONS",
-    });
+    let autoconfigURL = Services.prefs.getCharPref("mailnews.auto_config_url");
+    fetch(autoconfigURL, { method: "OPTIONS" });
+    let addonsURL = Services.prefs.getCharPref(
+      "mailnews.auto_config.addons_url"
+    );
+    if (new URL(autoconfigURL).origin != new URL(addonsURL).origin) {
+      fetch(addonsURL, { method: "OPTIONS" });
+    }
   },
 
   /**
    * Resize the window based on the content height and width.
    * Since the sizeToContent() method doesn't account for the height of
    * wrapped text, we're checking if the width and height of the "mastervbox"
    * is taller than the window width and height. This is necessary to account
    * for l10n strings or the user manually resizing the window.