0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-http-head-response-has-no-body.js
isaacs 3e1b1dd4a9 Remove excessive copyright/license boilerplate
The copyright and license notice is already in the LICENSE file.  There
is no justifiable reason to also require that it be included in every
file, since the individual files are not individually distributed except
as part of the entire package.
2015-01-12 15:30:28 -08:00

39 lines
870 B
JavaScript

var common = require('../common');
var assert = require('assert');
var http = require('http');
// This test is to make sure that when the HTTP server
// responds to a HEAD request, it does not send any body.
// In this case it was sending '0\r\n\r\n'
var server = http.createServer(function(req, res) {
res.writeHead(200); // broken: defaults to TE chunked
res.end();
});
server.listen(common.PORT);
var responseComplete = false;
server.on('listening', function() {
var req = http.request({
port: common.PORT,
method: 'HEAD',
path: '/'
}, function(res) {
common.error('response');
res.on('end', function() {
common.error('response end');
server.close();
responseComplete = true;
});
res.resume();
});
common.error('req');
req.end();
});
process.on('exit', function() {
assert.ok(responseComplete);
});