@@ -45,14 +45,20 @@ function makeHttp11Request(cb) {
45
45
function makeHttp10Request ( cb ) {
46
46
// We have to manually make HTTP/1.0 requests since Node does not allow sending them:
47
47
const socket = net . connect ( { port : server . address ( ) . port } , function ( ) {
48
+ socket . on ( 'error' , common . mustNotCall ( ) ) ;
49
+
48
50
socket . write ( 'GET / HTTP/1.0\r\n' +
49
51
'Host: localhost:' + server . address ( ) . port + '\r\n' +
50
52
'\r\n' ) ;
51
- socket . resume ( ) ; // Ignore the response itself
53
+ socket . end ( ) ; // we are done sending data
54
+ socket . resume ( ) ;
52
55
53
- setTimeout ( function ( ) {
54
- cb ( socket ) ;
55
- } , common . platformTimeout ( 50 ) ) ;
56
+ // Wait for response to be sent before invoking callback
57
+ socket . on ( 'close' , function ( ) {
58
+ setTimeout ( function ( ) {
59
+ cb ( socket ) ;
60
+ } , common . platformTimeout ( 100 ) ) ;
61
+ } ) ;
56
62
} ) ;
57
63
}
58
64
@@ -63,7 +69,8 @@ server.listen(0, function() {
63
69
assert . strictEqual ( firstSocket , secondSocket ) ;
64
70
65
71
makeHttp10Request ( function ( socket ) {
66
- // The server should have immediately closed the HTTP/1.0 socket:
72
+ // We waited for the HTTP response above, so
73
+ // the server should have immediately closed the HTTP/1.0 socket:
67
74
assert . strictEqual ( socket . closed , true ) ;
68
75
server . close ( ) ;
69
76
} ) ;
0 commit comments