1'use strict'; 2const common = require('../common'); 3const http = require('http'); 4 5// This test is to make sure that when the HTTP server 6// responds to a HEAD request with data to res.end, 7// it does not send any body but the response is sent 8// anyway. 9 10const server = http.createServer(function(req, res) { 11 res.end('FAIL'); // broken: sends FAIL from hot path. 12}); 13server.listen(0); 14 15server.on('listening', common.mustCall(function() { 16 const req = http.request({ 17 port: this.address().port, 18 method: 'HEAD', 19 path: '/' 20 }, common.mustCall(function(res) { 21 res.on('end', common.mustCall(function() { 22 server.close(); 23 })); 24 res.resume(); 25 })); 26 req.end(); 27})); 28