Skip to content

Commit

Permalink
Fix issue #895: Handle requests to ::1 in localhost test - 6 of 6 tes…
Browse files Browse the repository at this point in the history
…t pass
  • Loading branch information
n00nchi authored and KernelDeimos committed Oct 7, 2024
1 parent 7f7d93a commit 165d05e
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions test/localhost.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ const http = require('http');
const request = require('request');

test('can connect from all localhost addresses', t => {
const server = http.createServer(ecstatic(`${__dirname}/public/subdir`));
t.on('end', () => { server.close(); });
server.listen(0, () => {
const port = server.address().port;
const addresses = [
'localhost',
'127.0.0.1',
'::1',
];
const server = http.createServer(ecstatic(`${__dirname}/public/subdir`));
t.on('end', () => { server.close(); });
server.listen(0, () => {
const port = server.address().port;
const addresses = [
'localhost',
'127.0.0.1',
'::1',
];

t.plan(addresses.length * 2);
for (const address of addresses) {
request.get(`http://${address}:${port}/index.html`, (err, res, body) => {
t.error(err);
t.equal(res.statusCode, 200);
});
}
});
});
t.plan(addresses.length * 2);

for (const address of addresses) {
request.get(`http://[${address}]:${port}/index.html`, (err, res, body) => {
t.error(err);
t.equal(res.statusCode, 200);
});
}
});
});

0 comments on commit 165d05e

Please # to comment.