Permalink
Browse files

[fix] hack to call .end() explicitly, enable error handler, at this p…

…oint the test/http/http-test.js all passed
  • Loading branch information...
cronopio committed Jul 29, 2013
1 parent da6f345 commit 45c874e36fe61709a1d8d31e836ec820421985df
Showing with 12 additions and 15 deletions.
  1. +12 −15 lib/node-http-proxy/streams/proxy.js
@@ -72,56 +72,53 @@ var ProxyStream = module.exports = function ProxyStream(response, options) {
self.emit('readable');
});

// HACK: please fix it
// Should we call end() splicity?
self.end();

/*

//
// Handle 'error' events from the `reverseProxy`. Setup timeout override if needed
//
self.request.once('error', proxyError);
/*
// Set a timeout on the socket if `this.timeout` is specified.
reverseProxy.once('socket', function (socket) {
if (self.timeout) {
socket.setTimeout(self.timeout);
}
}); */

/*
//
// #### function proxyError (err)
// #### @err {Error} Error contacting the proxy target
// Short-circuits `res` in the event of any error when
// contacting the proxy target at `host` / `port`.
//
function proxyError(err) {
errState = true;
//
// Emit an `error` event, allowing the application to use custom
// error handling. The error handler should end the response.
//
if (self.emit('proxyError', err, req, res)) {
return;
}
res.writeHead(500, { 'Content-Type': 'text/plain' });
// if (self.emit('proxyError', err, req, res)) {
// return;
// }

if (req.method !== 'HEAD') {
response.writeHead(500, { 'Content-Type': 'text/plain' });
if (self.request.method !== 'HEAD') {
//
// This NODE_ENV=production behavior is mimics Express and
// Connect.
//
res.write(process.env.NODE_ENV === 'production'
response.write(process.env.NODE_ENV === 'production'
? 'Internal Server Error'
: 'An error has occurred: ' + JSON.stringify(err)
);
}

try { res.end() }
try { response.end() }
catch (ex) { console.error("res.end error: %s", ex.message) }
}
*/
});

};

0 comments on commit 45c874e

Please sign in to comment.