@@ -353,18 +353,7 @@ function writeHead(statusCode, reason, obj) {
353353// Docs-only deprecated: DEP0063
354354ServerResponse . prototype . writeHeader = ServerResponse . prototype . writeHead ;
355355
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 ) {
368357 this [ kIncomingMessage ] = options . IncomingMessage || IncomingMessage ;
369358 this [ kServerResponse ] = options . ServerResponse || ServerResponse ;
370359
@@ -377,7 +366,21 @@ function Server(options, requestListener) {
377366 if ( insecureHTTPParser !== undefined )
378367 validateBoolean ( insecureHTTPParser , 'options.insecureHTTPParser' ) ;
379368 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+ }
380382
383+ storeHTTPOptions . call ( this , options ) ;
381384 net . Server . call ( this , { allowHalfOpen : true } ) ;
382385
383386 if ( requestListener ) {
@@ -991,6 +994,7 @@ module.exports = {
991994 STATUS_CODES ,
992995 Server,
993996 ServerResponse,
997+ storeHTTPOptions,
994998 _connectionListener : connectionListener ,
995999 kServerResponse
9961000} ;
0 commit comments