Bug 1298056 - Fix HSTS preload update script so it will continue when requests result in errors. r=jcj, a=ritu
authorDavid Keeler <dkeeler@mozilla.com>
Fri, 26 Aug 2016 14:18:39 -0700
changeset 350011 524e793f63aa37fc7f8f911cfc3de8018fb4f311
parent 350010 d52d39c46763f03f5e663f5a40f22478380fdedc
child 350012 5ef82dde6a86dcc38c37cfacc9a6c71104aa55ed
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjcj, ritu
bugs1298056
milestone50.0a2
Bug 1298056 - Fix HSTS preload update script so it will continue when requests result in errors. r=jcj, a=ritu 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");
   }
 }