1 var common = require('../common');
2 var assert = require('assert');
3 var http = require('http');
4 var util = require('util');
6 var Duplex = require('stream').Duplex;
11 util.inherits(FakeAgent, http.Agent);
13 FakeAgent.prototype.createConnection = function createConnection() {
17 s._read = function read() {
19 return this.push(null);
22 this.push('HTTP/1.1 200 Ok\r\nTransfer-Encoding: chunked\r\n\r\n');
23 this.push('b\r\nhello world\r\n');
24 this.readable = false;
25 this.push('0\r\n\r\n');
29 s._write = function write(data, enc, cb) {
33 s.destroy = s.destroySoon = function destroy() {
34 this.writable = false;
43 var req = http.request({
44 agent: new FakeAgent()
46 res.on('data', function(chunk) {
50 res.on('end', function() {
56 process.on('exit', function() {
57 assert.equal(received, 'hello world');
58 assert.equal(ended, 1);