@@ -10,6 +10,13 @@ const server = http.createServer(function(request, response) {
1010  // For HTTP/1.0, the connection should be closed after the response automatically. 
1111  response . removeHeader ( 'connection' ) ; 
1212
13+   if  ( request . httpVersion  ===  '1.0' )  { 
14+     const  socket  =  request . socket ; 
15+     response . on ( 'finish' ,  common . mustCall ( function ( )  { 
16+       assert . ok ( socket . writableEnded ) ; 
17+     } ) ) ; 
18+   } 
19+ 
1320  response . end ( 'beep boop\n' ) ; 
1421} ) ; 
1522
@@ -50,9 +57,7 @@ function makeHttp10Request(cb) {
5057                '\r\n' ) ; 
5158    socket . resume ( ) ;  // Ignore the response itself 
5259
53-     setTimeout ( function ( )  { 
54-       cb ( socket ) ; 
55-     } ,  common . platformTimeout ( 50 ) ) ; 
60+     socket . on ( 'close' ,  cb ) ; 
5661  } ) ; 
5762} 
5863
@@ -62,9 +67,7 @@ server.listen(0, function() {
6267      // Both HTTP/1.1 requests should have used the same socket: 
6368      assert . strictEqual ( firstSocket ,  secondSocket ) ; 
6469
65-       makeHttp10Request ( function ( socket )  { 
66-         // The server should have immediately closed the HTTP/1.0 socket: 
67-         assert . strictEqual ( socket . closed ,  true ) ; 
70+       makeHttp10Request ( function ( )  { 
6871        server . close ( ) ; 
6972      } ) ; 
7073    } ) ; 
0 commit comments