Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d51c856

Browse filesBrowse files
saitoxuaddaleax
authored andcommitted
test: fix test-http-status-reason-invalid-chars
Use port 0 instead of common.PORT, and use server address instead of localhost to follow writing test guideline. This is a part of Code And Learn at NodeFest 2016 Challenge in Tokyo. PR-URL: #9572 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 2ee3543 commit d51c856
Copy full SHA for d51c856

File tree

Expand file treeCollapse file tree

1 file changed

+5
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-2
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-http-status-reason-invalid-chars.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-status-reason-invalid-chars.js
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const common = require('../common');
44
const assert = require('assert');
55
const http = require('http');
6+
const net = require('net');
67

78
function explicit(req, res) {
89
assert.throws(() => {
@@ -32,8 +33,10 @@ const server = http.createServer((req, res) => {
3233
} else {
3334
implicit(req, res);
3435
}
35-
}).listen(common.PORT, common.mustCall(() => {
36-
const url = `http://localhost:${common.PORT}`;
36+
}).listen(0, common.mustCall(() => {
37+
const addr = server.address().address;
38+
const hostname = net.isIPv6(addr) ? `[${addr}1]` : addr;
39+
const url = `http://${hostname}:${server.address().port}`;
3740
let left = 2;
3841
const check = common.mustCall((res) => {
3942
left--;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.