Skip to content

Commit 2243db8

Browse files
committed
https: align https server options with http options
1 parent f7a5d5e commit 2243db8

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

lib/_http_server.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -353,18 +353,7 @@ function writeHead(statusCode, reason, obj) {
353353
// Docs-only deprecated: DEP0063
354354
ServerResponse.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
};

lib/https.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,14 @@ const tls = require('tls');
4040
const { Agent: HttpAgent } = require('_http_agent');
4141
const {
4242
Server: HttpServer,
43+
storeHTTPOptions,
4344
_connectionListener,
44-
kServerResponse
4545
} = require('_http_server');
4646
const { ClientRequest } = require('_http_client');
4747
let debug = require('internal/util/debuglog').debuglog('https', (fn) => {
4848
debug = fn;
4949
});
5050
const { URL, urlToHttpOptions, searchParamsSymbol } = require('internal/url');
51-
const { IncomingMessage, ServerResponse } = require('http');
52-
const { kIncomingMessage } = require('_http_common');
53-
const { validateInteger } = require('internal/validators');
5451

5552
function Server(opts, requestListener) {
5653
if (!(this instanceof Server)) return new Server(opts, requestListener);
@@ -68,15 +65,7 @@ function Server(opts, requestListener) {
6865
opts.ALPNProtocols = ['http/1.1'];
6966
}
7067

71-
this.maxHeaderSize = 0;
72-
if (opts.maxHeaderSize !== undefined) {
73-
validateInteger(opts.maxHeaderSize, 'maxHeaderSize', 0);
74-
this.maxHeaderSize = opts.maxHeaderSize;
75-
}
76-
77-
this[kIncomingMessage] = opts.IncomingMessage || IncomingMessage;
78-
this[kServerResponse] = opts.ServerResponse || ServerResponse;
79-
68+
FunctionPrototypeCall(storeHTTPOptions, this, opts);
8069
FunctionPrototypeCall(tls.Server, this, opts, _connectionListener);
8170

8271
this.httpAllowHalfOpen = false;

0 commit comments

Comments
 (0)