Skip to content

Commit

Permalink
Only load http2 if preferHttp1 is false
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-pape committed Feb 22, 2018
1 parent d103fd6 commit 0c7270c
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 0c7270c

Please sign in to comment.