Skip to content

Commit d51c856

Browse 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 <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Shigeki Ohtsu <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 2ee3543 commit d51c856

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
constcommon=require('../common');
44
constassert=require('assert');
55
consthttp=require('http');
6+
constnet=require('net');
67

78
functionexplicit(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-
consturl=`http://localhost:${common.PORT}`;
36+
}).listen(0,common.mustCall(()=>{
37+
constaddr=server.address().address;
38+
consthostname=net.isIPv6(addr) ? `[${addr}1]` : addr;
39+
consturl=`http://${hostname}:${server.address().port}`;
3740
letleft=2;
3841
constcheck=common.mustCall((res)=>{
3942
left--;

0 commit comments

Comments
(0)