diff --git a/test/parallel/test-http-remove-header-stays-removed.js b/test/parallel/test-http-remove-header-stays-removed.js index 3885ebd905f758..6eba1799cd7d3f 100644 --- a/test/parallel/test-http-remove-header-stays-removed.js +++ b/test/parallel/test-http-remove-header-stays-removed.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const http = require('http'); @@ -56,6 +56,14 @@ server.listen(0, function() { res.setEncoding('ascii'); res.on('data', function(chunk) { response += chunk; + if (response === 'beep boop\n') { + setTimeout(function() { + // The socket should be closed immediately, with no keep-alive, because + // no content-length or transfer-encoding are used: + assert.strictEqual(res.socket.closed, true); + server.close(); + }, common.platformTimeout(15)); + } }); }); });