@@ -45,14 +45,20 @@ function makeHttp11Request(cb) {
4545function makeHttp10Request ( cb ) {
4646 // We have to manually make HTTP/1.0 requests since Node does not allow sending them:
4747 const socket = net . connect ( { port : server . address ( ) . port } , function ( ) {
48+ socket . on ( 'error' , common . mustNotCall ( ) ) ;
49+
4850 socket . write ( 'GET / HTTP/1.0\r\n' +
4951 'Host: localhost:' + server . address ( ) . port + '\r\n' +
5052 '\r\n' ) ;
51- socket . resume ( ) ; // Ignore the response itself
53+ socket . end ( ) ; // we are done sending data
54+ socket . resume ( ) ;
5255
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+ } ) ;
5662 } ) ;
5763}
5864
@@ -63,7 +69,8 @@ server.listen(0, function() {
6369 assert . strictEqual ( firstSocket , secondSocket ) ;
6470
6571 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:
6774 assert . strictEqual ( socket . closed , true ) ;
6875 server . close ( ) ;
6976 } ) ;
0 commit comments