• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const assert = require('assert');
4const http = require('http');
5
6const server = http.createServer();
7
8server.on('request', function(req, res) {
9  res.writeHead(200, { 'foo': 'bar' });
10  res.flushHeaders();
11  res.flushHeaders(); // Should be idempotent.
12});
13server.listen(0, common.localhostIPv4, function() {
14  const req = http.request({
15    method: 'GET',
16    host: common.localhostIPv4,
17    port: this.address().port,
18  }, onResponse);
19
20  req.end();
21
22  function onResponse(res) {
23    assert.strictEqual(res.headers.foo, 'bar');
24    res.destroy();
25    server.close();
26  }
27});
28