File tree 1 file changed +5
-5
lines changed
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -27,26 +27,26 @@ if (!common.hasMultiLocalhost())
27
27
const http = require ( 'http' ) ;
28
28
const assert = require ( 'assert' ) ;
29
29
30
- const server = http . createServer ( function ( req , res ) {
30
+ const server = http . createServer ( ( req , res ) => {
31
31
console . log ( `Connect from: ${ req . connection . remoteAddress } ` ) ;
32
32
assert . strictEqual ( req . connection . remoteAddress , '127.0.0.2' ) ;
33
33
34
- req . on ( 'end' , function ( ) {
34
+ req . on ( 'end' , ( ) => {
35
35
res . writeHead ( 200 , { 'Content-Type' : 'text/plain' } ) ;
36
36
res . end ( `You are from: ${ req . connection . remoteAddress } ` ) ;
37
37
} ) ;
38
38
req . resume ( ) ;
39
39
} ) ;
40
40
41
- server . listen ( 0 , '127.0.0.1' , function ( ) {
41
+ server . listen ( 0 , '127.0.0.1' , ( ) => {
42
42
const options = { host : 'localhost' ,
43
- port : this . address ( ) . port ,
43
+ port : server . address ( ) . port ,
44
44
path : '/' ,
45
45
method : 'GET' ,
46
46
localAddress : '127.0.0.2' } ;
47
47
48
48
const req = http . request ( options , function ( res ) {
49
- res . on ( 'end' , function ( ) {
49
+ res . on ( 'end' , ( ) => {
50
50
server . close ( ) ;
51
51
process . exit ( ) ;
52
52
} ) ;
You can’t perform that action at this time.
0 commit comments