blob: d794aae446c4fa4c6cccd8131973688251c4b3b7 (
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
28
29
30
31
32
33
34
35
36
37
38
39
|
'use strict';
// see https://github.com/joyent/node/issues/3257
var common = require('../common');
var assert = require('assert');
var http = require('http');
var server = http.createServer(function(req, res) {
req.resume();
req.once('end', function() {
res.writeHead(200);
res.end();
server.close();
});
});
server.listen(common.PIPE, function() {
var req = http.request({
socketPath: common.PIPE,
headers: {'Content-Length':'1'},
method: 'POST',
path: '/'
});
req.write('.');
sched(function() { req.end(); }, 5);
});
// schedule a callback after `ticks` event loop ticks
function sched(cb, ticks) {
function fn() {
if (--ticks)
setImmediate(fn);
else
cb();
}
setImmediate(fn);
}
|