• 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(common.mustCall(function(req, res) {
7  res.end('testing ended state', common.mustCall());
8  assert.strictEqual(res.writableCorked, 0);
9  res.end(common.mustCall());
10  assert.strictEqual(res.writableCorked, 0);
11  res.on('finish', common.mustCall(() => {
12    res.end(common.mustCall((err) => {
13      assert.strictEqual(err.code, 'ERR_STREAM_ALREADY_FINISHED');
14      server.close();
15    }));
16    assert.strictEqual(res.writableCorked, 0);
17  }));
18}));
19
20server.listen(0);
21
22server.on('listening', common.mustCall(function() {
23  http
24    .request({
25      port: server.address().port,
26      method: 'GET',
27      path: '/'
28    })
29    .end();
30}));
31