1 var common = require('../common');
2 var assert = require('assert');
4 var http = require('http');
6 var Stream = require('stream');
9 // An old-style readable stream.
10 // The Readable class prevents this behavior.
11 var src = new Stream();
13 // start out paused, just so we don't miss anything yet.
15 src.pause = function() {
18 src.resume = function() {
22 var chunks = [ '', 'asdf', '', 'foo', '', 'bar', '' ];
23 var interval = setInterval(function() {
27 var chunk = chunks.shift();
28 if (chunk !== undefined) {
29 src.emit('data', chunk);
32 clearInterval(interval);
40 var expect = 'asdffoobar';
42 var server = http.createServer(function(req, res) {
44 req.setEncoding('utf8');
45 req.on('data', function(c) {
48 req.on('end', function() {
49 assert.equal(actual, expect);
55 server.listen(common.PORT, function() {
56 var req = http.request({ port: common.PORT, method: 'POST' });
58 req.on('response', function(res) {
59 res.setEncoding('utf8');
60 res.on('data', function(c) {
63 res.on('end', function() {
64 assert.equal(actual, expect);
70 process.on('exit', function(c) {
71 if (!c) console.log('ok');