@@ -353,18 +353,7 @@ function writeHead(statusCode, reason, obj) {
353
353
// Docs-only deprecated: DEP0063
354
354
ServerResponse . prototype . writeHeader = ServerResponse . prototype . writeHead ;
355
355
356
- function Server ( options , requestListener ) {
357
- if ( ! ( this instanceof Server ) ) return new Server ( options , requestListener ) ;
358
-
359
- if ( typeof options === 'function' ) {
360
- requestListener = options ;
361
- options = { } ;
362
- } else if ( options == null || typeof options === 'object' ) {
363
- options = { ...options } ;
364
- } else {
365
- throw new ERR_INVALID_ARG_TYPE ( 'options' , 'object' , options ) ;
366
- }
367
-
356
+ function storeHTTPOptions ( options ) {
368
357
this [ kIncomingMessage ] = options . IncomingMessage || IncomingMessage ;
369
358
this [ kServerResponse ] = options . ServerResponse || ServerResponse ;
370
359
@@ -377,7 +366,21 @@ function Server(options, requestListener) {
377
366
if ( insecureHTTPParser !== undefined )
378
367
validateBoolean ( insecureHTTPParser , 'options.insecureHTTPParser' ) ;
379
368
this . insecureHTTPParser = insecureHTTPParser ;
369
+ }
370
+
371
+ function Server ( options , requestListener ) {
372
+ if ( ! ( this instanceof Server ) ) return new Server ( options , requestListener ) ;
373
+
374
+ if ( typeof options === 'function' ) {
375
+ requestListener = options ;
376
+ options = { } ;
377
+ } else if ( options == null || typeof options === 'object' ) {
378
+ options = { ...options } ;
379
+ } else {
380
+ throw new ERR_INVALID_ARG_TYPE ( 'options' , 'object' , options ) ;
381
+ }
380
382
383
+ storeHTTPOptions . call ( this , options ) ;
381
384
net . Server . call ( this , { allowHalfOpen : true } ) ;
382
385
383
386
if ( requestListener ) {
@@ -991,6 +994,7 @@ module.exports = {
991
994
STATUS_CODES ,
992
995
Server,
993
996
ServerResponse,
997
+ storeHTTPOptions,
994
998
_connectionListener : connectionListener ,
995
999
kServerResponse
996
1000
} ;
0 commit comments