2
2
require ( '../common' ) ;
3
3
const assert = require ( 'assert' ) ;
4
4
const http = require ( 'http' ) ;
5
+ const debug = require ( 'util' ) . debuglog ( 'test' ) ;
5
6
6
7
const testResBody = 'other stuff!\n' ;
7
8
const kMessageCount = 2 ;
8
9
9
10
const server = http . createServer ( ( req , res ) => {
10
11
for ( let i = 0 ; i < kMessageCount ; i ++ ) {
11
- console . error ( `Server sending informational message #${ i } ...` ) ;
12
+ debug ( `Server sending informational message #${ i } ...` ) ;
12
13
res . writeProcessing ( ) ;
13
14
}
14
- console . error ( 'Server sending full response...' ) ;
15
+ debug ( 'Server sending full response...' ) ;
15
16
res . writeHead ( 200 , {
16
17
'Content-Type' : 'text/plain' ,
17
18
'ABCD' : '1'
@@ -25,7 +26,7 @@ server.listen(0, function() {
25
26
path : '/world'
26
27
} ) ;
27
28
req . end ( ) ;
28
- console . error ( 'Client sending request...' ) ;
29
+ debug ( 'Client sending request...' ) ;
29
30
30
31
let body = '' ;
31
32
let infoCount = 0 ;
@@ -40,7 +41,7 @@ server.listen(0, function() {
40
41
res . setEncoding ( 'utf8' ) ;
41
42
res . on ( 'data' , function ( chunk ) { body += chunk ; } ) ;
42
43
res . on ( 'end' , function ( ) {
43
- console . error ( 'Got full response.' ) ;
44
+ debug ( 'Got full response.' ) ;
44
45
assert . strictEqual ( body , testResBody ) ;
45
46
assert . ok ( 'abcd' in res . headers ) ;
46
47
server . close ( ) ;
0 commit comments