diff --git a/lib/tools/isHttp2.js b/lib/tools/isHttp2.js index 0af9753..acea838 100644 --- a/lib/tools/isHttp2.js +++ b/lib/tools/isHttp2.js @@ -13,7 +13,16 @@ var isHttp2 = function() { .then(function(result) { - if (result.isHttp2) { + if (result.isHttp) { + debug('The website is not even in HTTPS'); + + data.toolsResults.http2 = { + metrics: { + http2: false + } + }; + + } else if (result.isHttp2) { debug('HTTP/2 (or SPDY) is supported'); data.toolsResults.http2 = { @@ -65,21 +74,30 @@ var isHttp2 = function() { this.checkHttp2 = function(data) { var deferred = Q.defer(); - var domain = this.getDomain(data); - - // To make is-http2 work, you need to have openssl in a version greater than 1.0.0 installed and available in your $path. - http2(domain, {includeSpdy: true}) - - .then(function(result) { - deferred.resolve(result); - }) + // Check if it's HTTPS first + if (this.getProtocol(data) === 'http:') { - .catch(function(error) { - debug('Error while checking HTTP2 support:'); - debug(error); - deferred.reject('Error while checking for HTTP2 support'); + deferred.resolve({ + isHttp: true }); + } else { + + // To make is-http2 work, you need to have openssl in a version greater than 1.0.0 installed and available in your $path. + http2(this.getDomain(data), {includeSpdy: true}) + + .then(function(result) { + deferred.resolve(result); + }) + + .catch(function(error) { + debug('Error while checking HTTP2 support:'); + debug(error); + deferred.reject('Error while checking for HTTP2 support'); + }); + + } + return deferred.promise; }; };