bug 1298056 - fix HSTS preload update script so it will continue when requests result in errors r?jcj draft
authorDavid Keeler <dkeeler@mozilla.com>
Fri, 26 Aug 2016 14:18:39 -0700
changeset 406301 96e9e1c05520fab13f79990a99a4c507fe83fd44
parent 406178 a65b35c8e5b17c2585968974aef1da67a8c56642
child 529621 4993a797e07b08e1b2352631b7720ddf899ac63a
push id27684
push userdkeeler@mozilla.com
push dateFri, 26 Aug 2016 21:57:16 +0000
reviewersjcj
bugs1298056
milestone51.0a1
bug 1298056 - fix HSTS preload update script so it will continue when requests result in errors r?jcj MozReview-Commit-ID: b697Aa4iqQ
security/manager/tools/getHSTSPreloadList.js
--- a/security/manager/tools/getHSTSPreloadList.js
+++ b/security/manager/tools/getHSTSPreloadList.js
@@ -177,27 +177,38 @@ RedirectAndAuthStopper.prototype = {
 function getHSTSStatus(host, resultList) {
   var req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
             .createInstance(Ci.nsIXMLHttpRequest);
   var inResultList = false;
   var uri = "https://" + host.name + "/";
   req.open("GET", uri, true);
   req.timeout = REQUEST_TIMEOUT;
   req.channel.notificationCallbacks = new RedirectAndAuthStopper();
+
+  let errorhandler = (evt) => {
+    dump(`ERROR: error making request to ${host.name} (type=${evt.type})\n`);
+    if (!inResultList) {
+      inResultList = true;
+      resultList.push(processStsHeader(host, null, req.status,
+                                       req.channel.securityInfo));
+    }
+  };
+  req.onerror = errorhandler;
+  req.ontimeout = errorhandler;
+  req.onabort = errorhandler;
+
   req.onload = function(event) {
     if (!inResultList) {
       inResultList = true;
       var header = req.getResponseHeader("strict-transport-security");
       resultList.push(processStsHeader(host, header, req.status,
                                        req.channel.securityInfo));
     }
   };
-  req.onerror = function(e) {
-    dump("ERROR: network error making request to " + host.name + ": " + e + "\n");
-  };
+
   try {
     req.send();
   }
   catch (e) {
     dump("ERROR: exception making request to " + host.name + ": " + e + "\n");
   }
 }