File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -62,23 +62,25 @@ const { validateObject } = require('internal/validators');
6262function Server ( opts , requestListener ) {
6363 if ( ! ( this instanceof Server ) ) return new Server ( opts , requestListener ) ;
6464
65+ let ALPNProtocols = [ 'http/1.1' ] ;
6566 if ( typeof opts === 'function' ) {
6667 requestListener = opts ;
6768 opts = kEmptyObject ;
6869 } else if ( opts == null ) {
6970 opts = kEmptyObject ;
7071 } else {
7172 validateObject ( opts , 'options' ) ;
73+ // Only one of ALPNProtocols and ALPNCallback can be set, so make sure we
74+ // only set a default ALPNProtocols if the caller has not set either of them
75+ if ( opts . ALPNProtocols || opts . ALPNCallback )
76+ ALPNProtocols = undefined ;
7277 }
7378
7479 FunctionPrototypeCall ( storeHTTPOptions , this , opts ) ;
7580 FunctionPrototypeCall ( tls . Server , this ,
7681 {
7782 noDelay : true ,
78- // http/1.0 is not defined as Protocol IDs in IANA
79- // https://www.iana.org/assignments/tls-extensiontype-values
80- // /tls-extensiontype-values.xhtml#alpn-protocol-ids
81- ALPNProtocols : [ 'http/1.1' ] ,
83+ ALPNProtocols,
8284 ...opts ,
8385 } ,
8486 _connectionListener ) ;
Original file line number Diff line number Diff line change @@ -45,3 +45,14 @@ const dftProtocol = {};
4545 0 ) ;
4646 assert . strictEqual ( server . listeners ( 'request' ) . length , 0 ) ;
4747}
48+
49+
50+ // Validate that `createServer` only uses defaults when appropriate
51+ {
52+ const ALPNCallback = ( ) => { } ;
53+ const server = https . createServer ( {
54+ ALPNCallback,
55+ } ) ;
56+ assert . strictEqual ( server . ALPNProtocols , undefined ) ;
57+ assert . strictEqual ( server . ALPNCallback , ALPNCallback ) ;
58+ }
You can’t perform that action at this time.
0 commit comments