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: add type checking for hostname #12494

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
7 participants
@jasnell
Member

jasnell commented Apr 18, 2017

Add type checking for options.hostname / options.host Maintains the use of undefined and null for default localhost, but other falsy values (like false, 0 and NaN) are rejected.

Refs: #12488

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

http

Show outdated Hide outdated lib/_http_client.js
Show outdated Hide outdated lib/_http_client.js
@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Apr 18, 2017

Member

@mscdex Updated

Member

jasnell commented Apr 18, 2017

@mscdex Updated

@cjihrig

LGTM with a question.

Show outdated Hide outdated test/parallel/test-http-hostname-typechecking.js
Show outdated Hide outdated lib/_http_client.js
Show outdated Hide outdated lib/_http_client.js
@lpinca

lpinca approved these changes Apr 19, 2017

@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Apr 19, 2017

Member

@mscdex @lpinca ... updated!

Member

jasnell commented Apr 19, 2017

@mscdex @lpinca ... updated!

@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Apr 20, 2017

Member

@nodejs/ctc ... PTAL

Member

jasnell commented Apr 20, 2017

@nodejs/ctc ... PTAL

Show outdated Hide outdated test/parallel/test-http-hostname-typechecking.js
Show outdated Hide outdated test/parallel/test-http-hostname-typechecking.js
// These values are OK and should not throw synchronously
['', undefined, null].forEach((v) => {
assert.doesNotThrow(() => {
http.request({hostname: v}).on('error', common.noop);

This comment has been minimized.

@thefourtheye

thefourtheye Apr 21, 2017

Contributor

Why not common.mustNotCall() here?

@thefourtheye

thefourtheye Apr 21, 2017

Contributor

Why not common.mustNotCall() here?

This comment has been minimized.

@lpinca

lpinca Apr 21, 2017

Member

@jasnell's reply on a comment above for same question

The main part that this is testing is that the call to http.request() does not throw synchronously. The fact that it will emit the error event is non-sequential to this particular test. This is set simply to avoid the unhandled error exception.

@lpinca

lpinca Apr 21, 2017

Member

@jasnell's reply on a comment above for same question

The main part that this is testing is that the call to http.request() does not throw synchronously. The fact that it will emit the error event is non-sequential to this particular test. This is set simply to avoid the unhandled error exception.

This comment has been minimized.

@thefourtheye

thefourtheye Apr 21, 2017

Contributor

Mmmm, makes sense. Cool then.

@thefourtheye

thefourtheye Apr 21, 2017

Contributor

Mmmm, makes sense. Cool then.

http: add type checking for hostname
Add type checking for options.hostname / options.host
Maintains the use of `undefined` and `null` for default `localhost`,
but other falsy values (like `false`, `0` and `NaN`) are rejected.
@jasnell

This comment has been minimized.

Show comment
Hide comment
Member

jasnell commented Apr 24, 2017

@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Apr 24, 2017

Member

Linting error was from an unrelated commit

Member

jasnell commented Apr 24, 2017

Linting error was from an unrelated commit

jasnell added a commit that referenced this pull request Apr 24, 2017

http: add type checking for hostname
Add type checking for options.hostname / options.host
Maintains the use of `undefined` and `null` for default `localhost`,
but other falsy values (like `false`, `0` and `NaN`) are rejected.

PR-URL: #12494
Ref: #12488
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Apr 24, 2017

Member

Landed in 85a4e25

Member

jasnell commented Apr 24, 2017

Landed in 85a4e25

@jasnell jasnell closed this Apr 24, 2017

@addaleax addaleax referenced this pull request Apr 25, 2017

Closed

test: fixup test-http-hostname-typechecking #12627

3 of 3 tasks complete

addaleax added a commit to addaleax/node that referenced this pull request Apr 25, 2017

test: fixup test-http-hostname-typechecking
This test would currently create HTTP requests to localhost:80
and would time out on machines that actually had an server listening
there.

To address that, `end()` the requests that are generated.

PR-URL: nodejs#12627
Ref: nodejs#12494

addaleax added a commit that referenced this pull request Apr 27, 2017

test: fixup test-http-hostname-typechecking
This test would currently create HTTP requests to localhost:80
and would time out on machines that actually had an server listening
there.

To address that, `end()` the requests that are generated.

PR-URL: #12627
Ref: #12494
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>

@jasnell jasnell referenced this pull request May 11, 2017

Closed

8.0.0 Release Proposal #12220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment