Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-http-pause-resume-one-end.js « parallel « test - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6b98246cc271ac8a77bede31846dad063530bef2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';
const common = require('../common');
const http = require('http');

const server = http.Server(function(req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
  server.close();
});

server.listen(0, common.mustCall(function() {
  const opts = {
    port: this.address().port,
    headers: { connection: 'close' }
  };

  http.get(opts, common.mustCall(function(res) {
    res.on('data', common.mustCall(function() {
      res.pause();
      setImmediate(function() {
        res.resume();
      });
    }));

    res.on('end', common.mustCall(function() {}));
  }));
}));