test: replace anonymous closure functions with arrow functions
PR-URL: https://github.com/nodejs/node/pull/24443 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This commit is contained in:
parent
1db808ca5f
commit
3ec85763f6
@ -28,26 +28,26 @@ if (!common.hasMultiLocalhost())
|
|||||||
const http = require('http');
|
const http = require('http');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const server = http.createServer(function(req, res) {
|
const server = http.createServer((req, res) => {
|
||||||
console.log(`Connect from: ${req.connection.remoteAddress}`);
|
console.log(`Connect from: ${req.connection.remoteAddress}`);
|
||||||
assert.strictEqual(req.connection.remoteAddress, '127.0.0.2');
|
assert.strictEqual(req.connection.remoteAddress, '127.0.0.2');
|
||||||
|
|
||||||
req.on('end', function() {
|
req.on('end', () => {
|
||||||
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
||||||
res.end(`You are from: ${req.connection.remoteAddress}`);
|
res.end(`You are from: ${req.connection.remoteAddress}`);
|
||||||
});
|
});
|
||||||
req.resume();
|
req.resume();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(0, '127.0.0.1', function() {
|
server.listen(0, '127.0.0.1', () => {
|
||||||
const options = { host: 'localhost',
|
const options = { host: 'localhost',
|
||||||
port: this.address().port,
|
port: server.address().port,
|
||||||
path: '/',
|
path: '/',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
localAddress: '127.0.0.2' };
|
localAddress: '127.0.0.2' };
|
||||||
|
|
||||||
const req = http.request(options, function(res) {
|
const req = http.request(options, function(res) {
|
||||||
res.on('end', function() {
|
res.on('end', () => {
|
||||||
server.close();
|
server.close();
|
||||||
process.exit();
|
process.exit();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user