node/test/parallel/test-http-flush-response-headers.js
Ruben Bridgewater 463d1a490f
test,benchmark,doc: enable dot-notation rule
This enables the eslint dot-notation rule for all code instead of
only in /lib.

PR-URL: https://github.com/nodejs/node/pull/18749
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matheus Marchini <matheus@sthima.com>
2018-02-16 19:37:43 +01:00

28 lines
628 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const http = require('http');
const server = http.createServer();
server.on('request', function(req, res) {
res.writeHead(200, { 'foo': 'bar' });
res.flushHeaders();
res.flushHeaders(); // Should be idempotent.
});
server.listen(0, common.localhostIPv4, function() {
const req = http.request({
method: 'GET',
host: common.localhostIPv4,
port: this.address().port,
}, onResponse);
req.end();
function onResponse(res) {
assert.strictEqual(res.headers.foo, 'bar');
res.destroy();
server.close();
}
});