From 0c7270c488a6b7c0b4bad87ec28f13e619f86509 Mon Sep 17 00:00:00 2001 From: Nick Pape nickpape Date: Wed, 21 Feb 2018 17:00:13 -0800 Subject: [PATCH] Only load http2 if preferHttp1 is false --- src/index.coffee | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/index.coffee b/src/index.coffee index 2566e27..9a2fe02 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -13,10 +13,6 @@ send = require("send") tiny_lr = require("tiny-lr") apps = [] -http2 = undefined -try - http2 = require('http2') - class ConnectApp constructor: (options, startedCallback) -> @name = options.name || "Server" @@ -71,7 +67,12 @@ class ConnectApp @https.ca = fs.readFileSync __dirname + '/certs/server.crt' @https.passphrase = 'gulp' - if !@preferHttp1 && http2 + http2 = undefined + if !@preferHttp1 + try + http2 = require('http2') + + if http2 @https.allowHTTP1 = true @server = http2.createSecureServer(@https, @app) else