Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: else case is not reachable #24176

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const { IncomingMessage } = require('_http_incoming');
const {
ERR_HTTP_HEADERS_SENT,
ERR_HTTP_INVALID_STATUS_CODE,
ERR_INVALID_ARG_TYPE,
ERR_INVALID_CHAR
} = require('internal/errors').codes;
const Buffer = require('buffer').Buffer;
Expand Down Expand Up @@ -281,6 +282,8 @@ function Server(options, requestListener) {
options = {};
} else if (options == null || typeof options === 'object') {
options = util._extend({}, options);
} else {
throw new ERR_INVALID_ARG_TYPE('options', 'object', options);
}

this[kIncomingMessage] = options.IncomingMessage || IncomingMessage;
Expand Down
13 changes: 13 additions & 0 deletions test/parallel/test-http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ const http = require('http');
const url = require('url');
const qs = require('querystring');

// TODO: documentation does not allow Array as an option, so testing that
// should fail, but currently http.Server does not typecheck further than
// if `option` is `typeof object` - so we don't test that here right now
const invalid_options = [ 'foo', 42, true ];

invalid_options.forEach((option) => {
assert.throws(() => {
new http.Server(option);
}, {
code: 'ERR_INVALID_ARG_TYPE'
});
});

let request_number = 0;
let requests_sent = 0;
let server_response = '';
Expand Down