@@ -33,9 +33,14 @@ server.listen(0, common.mustCall(function() {
33
33
path : 'example.com:443'
34
34
} , common . mustNotCall ( ) ) ;
35
35
36
- req . on ( 'close' , common . mustCall ( ) ) ;
36
+ assert . strictEqual ( req . closed , false ) ;
37
+ req . on ( 'close' , common . mustCall ( ( ) => {
38
+ assert . strictEqual ( req . closed , true ) ;
39
+ } ) ) ;
37
40
38
41
req . on ( 'connect' , common . mustCall ( function ( res , socket , firstBodyChunk ) {
42
+ assert . strictEqual ( req . closed , false ) ;
43
+
39
44
console . error ( 'Client got CONNECT request' ) ;
40
45
41
46
// Make sure this request got removed from the pool.
@@ -54,10 +59,20 @@ server.listen(0, common.mustCall(function() {
54
59
// Test that the firstBodyChunk was not parsed as HTTP
55
60
assert . strictEqual ( data , 'Head' ) ;
56
61
62
+ let closeEmitted = false ;
63
+
64
+ req . on ( 'close' , common . mustCall ( ( ) => {
65
+ closeEmitted = true ;
66
+ } ) ) ;
67
+
57
68
socket . on ( 'data' , function ( buf ) {
69
+ assert . strictEqual ( req . closed , true ) ; // TODO: This should be false
70
+ assert . strictEqual ( closeEmitted , true ) ; // TODO: This should be false
58
71
data += buf . toString ( ) ;
59
72
} ) ;
60
73
socket . on ( 'end' , function ( ) {
74
+ assert . strictEqual ( req . closed , true ) ; // TODO: This should be false
75
+ assert . strictEqual ( closeEmitted , true ) ; // TODO: This should be false
61
76
assert . strictEqual ( data , 'HeadRequestEnd' ) ;
62
77
server . close ( ) ;
63
78
} ) ;
0 commit comments