summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-response-readable.js
blob: 07c0a40e4bf1a819b21bbf5c44609f3ccdb26891 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'use strict';
require('../common');
const assert = require('assert');
const http = require('http');

const testServer = new http.Server(function(req, res) {
  res.writeHead(200);
  res.end('Hello world');
});

testServer.listen(0, function() {
  http.get({ port: this.address().port }, function(res) {
    assert.equal(res.readable, true, 'res.readable initially true');
    res.on('end', function() {
      assert.equal(res.readable, false, 'res.readable set to false after end');
      testServer.close();
    });
    res.resume();
  });
});