Skip to content
Closed
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
test: fix test-http-status-reason-invalid-chars.js
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
  • Loading branch information
saitoxu committed Nov 18, 2016
commit 00597b3258b5b09216816fb1f08c81a2e2c75cd3
7 changes: 5 additions & 2 deletions test/parallel/test-http-status-reason-invalid-chars.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const common = require('../common');
const assert = require('assert');
const http = require('http');
const net = require('net');

function explicit(req, res) {
assert.throws(() => {
Expand Down Expand Up @@ -32,8 +33,10 @@ const server = http.createServer((req, res) => {
} else {
implicit(req, res);
}
}).listen(common.PORT, common.mustCall(() => {
const url = `http://localhost:${common.PORT}`;
}).listen(0, common.mustCall(() => {
const addr = server.address().address;
const hostname = net.isIPv6(addr) ? `[${addr}1]` : addr;
const url = `http://${hostname}:${server.address().port}`;
let left = 2;
const check = common.mustCall((res) => {
left--;
Expand Down