1
1
'use strict' ;
2
2
require ( '../common' ) ;
3
- var assert = require ( 'assert' ) ;
4
- var http = require ( 'http' ) ;
5
- var url = require ( 'url' ) ;
3
+ const assert = require ( 'assert' ) ;
4
+ const http = require ( 'http' ) ;
5
+ const url = require ( 'url' ) ;
6
6
7
7
var responses_sent = 0 ;
8
8
var responses_recvd = 0 ;
9
9
var body0 = '' ;
10
10
var body1 = '' ;
11
11
12
- var server = http . Server ( function ( req , res ) {
13
- if ( responses_sent == 0 ) {
14
- assert . equal ( 'GET' , req . method ) ;
15
- assert . equal ( '/hello' , url . parse ( req . url ) . pathname ) ;
12
+ const server = http . Server ( function ( req , res ) {
13
+ if ( responses_sent === 0 ) {
14
+ assert . strictEqual ( 'GET' , req . method ) ;
15
+ assert . strictEqual ( '/hello' , url . parse ( req . url ) . pathname ) ;
16
16
17
17
console . dir ( req . headers ) ;
18
- assert . equal ( true , 'accept' in req . headers ) ;
19
- assert . equal ( '*/*' , req . headers [ 'accept' ] ) ;
18
+ assert . strictEqual ( true , 'accept' in req . headers ) ;
19
+ assert . strictEqual ( '*/*' , req . headers [ 'accept' ] ) ;
20
20
21
- assert . equal ( true , 'foo' in req . headers ) ;
22
- assert . equal ( 'bar' , req . headers [ 'foo' ] ) ;
21
+ assert . strictEqual ( true , 'foo' in req . headers ) ;
22
+ assert . strictEqual ( 'bar' , req . headers [ 'foo' ] ) ;
23
23
}
24
24
25
- if ( responses_sent == 1 ) {
26
- assert . equal ( 'POST' , req . method ) ;
27
- assert . equal ( '/world' , url . parse ( req . url ) . pathname ) ;
25
+ if ( responses_sent === 1 ) {
26
+ assert . strictEqual ( 'POST' , req . method ) ;
27
+ assert . strictEqual ( '/world' , url . parse ( req . url ) . pathname ) ;
28
28
this . close ( ) ;
29
29
}
30
30
@@ -41,28 +41,28 @@ var server = http.Server(function(req, res) {
41
41
server . listen ( 0 ) ;
42
42
43
43
server . on ( 'listening' , function ( ) {
44
- var agent = new http . Agent ( { port : this . address ( ) . port , maxSockets : 1 } ) ;
44
+ const agent = new http . Agent ( { port : this . address ( ) . port , maxSockets : 1 } ) ;
45
45
http . get ( {
46
46
port : this . address ( ) . port ,
47
47
path : '/hello' ,
48
48
headers : { 'Accept' : '*/*' , 'Foo' : 'bar' } ,
49
49
agent : agent
50
50
} , function ( res ) {
51
- assert . equal ( 200 , res . statusCode ) ;
51
+ assert . strictEqual ( 200 , res . statusCode ) ;
52
52
responses_recvd += 1 ;
53
53
res . setEncoding ( 'utf8' ) ;
54
54
res . on ( 'data' , function ( chunk ) { body0 += chunk ; } ) ;
55
55
console . error ( 'Got /hello response' ) ;
56
56
} ) ;
57
57
58
58
setTimeout ( function ( ) {
59
- var req = http . request ( {
59
+ const req = http . request ( {
60
60
port : server . address ( ) . port ,
61
61
method : 'POST' ,
62
62
path : '/world' ,
63
63
agent : agent
64
64
} , function ( res ) {
65
- assert . equal ( 200 , res . statusCode ) ;
65
+ assert . strictEqual ( 200 , res . statusCode ) ;
66
66
responses_recvd += 1 ;
67
67
res . setEncoding ( 'utf8' ) ;
68
68
res . on ( 'data' , function ( chunk ) { body1 += chunk ; } ) ;
@@ -74,12 +74,11 @@ server.on('listening', function() {
74
74
75
75
process . on ( 'exit' , function ( ) {
76
76
console . error ( 'responses_recvd: ' + responses_recvd ) ;
77
- assert . equal ( 2 , responses_recvd ) ;
77
+ assert . strictEqual ( 2 , responses_recvd ) ;
78
78
79
79
console . error ( 'responses_sent: ' + responses_sent ) ;
80
- assert . equal ( 2 , responses_sent ) ;
80
+ assert . strictEqual ( 2 , responses_sent ) ;
81
81
82
- assert . equal ( 'The path was /hello' , body0 ) ;
83
- assert . equal ( 'The path was /world' , body1 ) ;
82
+ assert . strictEqual ( 'The path was /hello' , body0 ) ;
83
+ assert . strictEqual ( 'The path was /world' , body1 ) ;
84
84
} ) ;
85
-
0 commit comments