Browse Source

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>
v6
Yosuke Saito 8 years ago
committed by Michaël Zasso
parent
commit
c9509acfb5
  1. 7
      test/parallel/test-http-status-reason-invalid-chars.js

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

@ -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(() => {
@ -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--;

Loading…
Cancel
Save