1
1
'use strict' ;
2
- var common = require ( '../common' ) ;
3
- var assert = require ( 'assert' ) ;
2
+ const common = require ( '../common' ) ;
3
+ const assert = require ( 'assert' ) ;
4
4
5
5
if ( ! common . hasCrypto ) {
6
6
common . skip ( 'missing crypto' ) ;
7
7
return ;
8
8
}
9
- var https = require ( 'https' ) ;
9
+ const https = require ( 'https' ) ;
10
10
11
- var fs = require ( 'fs' ) ;
11
+ const fs = require ( 'fs' ) ;
12
12
13
- var key = fs . readFileSync ( common . fixturesDir + '/keys/agent1-key.pem' ) ;
14
- var cert = fs . readFileSync ( common . fixturesDir + '/keys/agent1-cert.pem' ) ;
13
+ const key = fs . readFileSync ( common . fixturesDir + '/keys/agent1-key.pem' ) ;
14
+ const cert = fs . readFileSync ( common . fixturesDir + '/keys/agent1-cert.pem' ) ;
15
15
16
16
// number of bytes discovered empirically to trigger the bug
17
- var data = Buffer . allocUnsafe ( 1024 * 32 + 1 ) ;
17
+ const data = Buffer . allocUnsafe ( 1024 * 32 + 1 ) ;
18
18
19
19
httpsTest ( ) ;
20
20
21
21
function httpsTest ( ) {
22
- var sopt = { key : key , cert : cert } ;
22
+ const sopt = { key : key , cert : cert } ;
23
23
24
- var server = https . createServer ( sopt , function ( req , res ) {
24
+ const server = https . createServer ( sopt , function ( req , res ) {
25
25
res . setHeader ( 'content-length' , data . length ) ;
26
26
res . end ( data ) ;
27
27
server . close ( ) ;
28
28
} ) ;
29
29
30
30
server . listen ( 0 , function ( ) {
31
- var opts = { port : this . address ( ) . port , rejectUnauthorized : false } ;
31
+ const opts = { port : this . address ( ) . port , rejectUnauthorized : false } ;
32
32
https . get ( opts ) . on ( 'response' , function ( res ) {
33
33
test ( res ) ;
34
34
} ) ;
@@ -38,14 +38,14 @@ function httpsTest() {
38
38
39
39
function test ( res ) {
40
40
res . on ( 'end' , function ( ) {
41
- assert . equal ( res . _readableState . length , 0 ) ;
42
- assert . equal ( bytes , data . length ) ;
41
+ assert . strictEqual ( res . _readableState . length , 0 ) ;
42
+ assert . strictEqual ( bytes , data . length ) ;
43
43
console . log ( 'ok' ) ;
44
44
} ) ;
45
45
46
46
// Pause and then resume on each chunk, to ensure that there will be
47
47
// a lone byte hanging out at the very end.
48
- var bytes = 0 ;
48
+ let bytes = 0 ;
49
49
res . on ( 'data' , function ( chunk ) {
50
50
bytes += chunk . length ;
51
51
this . pause ( ) ;
0 commit comments