Skip to content

Commit

Permalink
Merge pull request #250 from nickpape-msft/nickpape/lazy-load-http2
Browse files Browse the repository at this point in the history
Only try requiring `http2` if preferHttp1 is false
  • Loading branch information
avevlad authored Feb 22, 2018
2 parents d103fd6 + 0c7270c commit 13db10c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 13db10c

Please sign in to comment.