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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
fe1dcb5873
commit
c9509acfb5
@ -3,6 +3,7 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
const net = require('net');
|
||||||
|
|
||||||
function explicit(req, res) {
|
function explicit(req, res) {
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
@ -32,8 +33,10 @@ const server = http.createServer((req, res) => {
|
|||||||
} else {
|
} else {
|
||||||
implicit(req, res);
|
implicit(req, res);
|
||||||
}
|
}
|
||||||
}).listen(common.PORT, common.mustCall(() => {
|
}).listen(0, common.mustCall(() => {
|
||||||
const url = `http://localhost:${common.PORT}`;
|
const addr = server.address().address;
|
||||||
|
const hostname = net.isIPv6(addr) ? `[${addr}1]` : addr;
|
||||||
|
const url = `http://${hostname}:${server.address().port}`;
|
||||||
let left = 2;
|
let left = 2;
|
||||||
const check = common.mustCall((res) => {
|
const check = common.mustCall((res) => {
|
||||||
left--;
|
left--;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user