1'use strict';
2const common = require('../common');
3const assert = require('assert');
4const http = require('http');
5
6{
7  const server = http.createServer(common.mustCall((req, res) => {
8    res.end('asd');
9  }));
10
11  server.listen(0, common.mustCall(() => {
12    http.get({
13      port: server.address().port
14    }, common.mustCall((res) => {
15      assert.strictEqual(res.destroyed, false);
16      res.destroy();
17      assert.strictEqual(res.destroyed, true);
18      res.on('close', common.mustCall(() => {
19        server.close();
20      }));
21    }));
22  }));
23}
24
25{
26  const server = http.createServer(common.mustCall((req, res) => {
27    res.end('asd');
28  }));
29
30  server.listen(0, common.mustCall(() => {
31    http.get({
32      port: server.address().port
33    }, common.mustCall((res) => {
34      assert.strictEqual(res.destroyed, false);
35      res.on('close', common.mustCall(() => {
36        assert.strictEqual(res.destroyed, true);
37        server.close();
38      })).resume();
39    }));
40  }));
41}
42