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