Skip to content
Browse files

fix logic errors in ResponseBuilder that prevented request from pipin…

…g to it.
  • Loading branch information...
1 parent bd5d1f4 commit e420e0afe5aaa8e957fd5f8aeb186acddac7f2c6 @nrstott committed Jan 13, 2012
Showing with 16 additions and 5 deletions.
  1. +16 −5 lib/bogart.js
View
21 lib/bogart.js
@@ -567,11 +567,12 @@ exports.stream = function() {
var ResponseBuilder = exports.ResponseBuilder = function(viewEngine) {
var Stream = require('stream')
- , responseBuilder = Object.create(merge({}, Q.defer(), Stream.prototype))
+ , responseBuilder = Object.create(Q.defer())
, forEachCallback
, forEachDeferred = Q.defer()
, response = { headers: {}, status: 200, body: {} }
- , waiting = [];
+ , waiting = []
+ , ended = false;
var send = function(data) {
if (typeof data === 'string') {
@@ -583,7 +584,18 @@ var ResponseBuilder = exports.ResponseBuilder = function(viewEngine) {
}
};
- Stream.call(responseBuilder);
+ responseBuilder.writable = true;
+
+ responseBuilder.on = function(event, callback) {
+ };
+
+ responseBuilder.emit = function(event) {
+ console.log('emit', event);
+ };
+
+ responseBuilder.removeListener = function(event, callback) {
+
+ };
/**
* Send response data
@@ -597,7 +609,7 @@ var ResponseBuilder = exports.ResponseBuilder = function(viewEngine) {
* @param {String | ForEachable | Buffer} data Data to send
* @api public
*/
- responseBuilder.send = function(data) {
+ responseBuilder.send = responseBuilder.write = function(data) {
if (typeof forEachCallback === 'function') {
send(data);
} else {
@@ -666,7 +678,6 @@ var ResponseBuilder = exports.ResponseBuilder = function(viewEngine) {
});
response.body.forEach = function(callback) {
-
forEachCallback = callback;
if (waiting.length > 0) {

0 comments on commit e420e0a

Please sign in to comment.
Something went wrong with that request. Please try again.