Skip to content
Permalink
Browse files

[fix] remove old legacy code

  • Loading branch information...
yawnt committed Jun 12, 2013
1 parent 374eb93 commit 27d23592d176445437080efe931cc910027cb711
Showing with 1 addition and 51 deletions.
  1. +1 −51 lib/node-http-proxy/http-proxy.js
@@ -93,12 +93,7 @@ util.inherits(HttpProxy, events.EventEmitter);
HttpProxy.prototype.proxyRequest = function (req, res, options) {
var self = this,
errState = false,
target = this.target(options),
location,
outgoing,
draining,
buffer,
pReq;
target = this.target(options);

// If this is a DELETE request then set the 'content-length'
// header (if it is not already set)
@@ -201,51 +196,6 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
//
req.on('error', proxyError);

//
// For each data `chunk` received from the incoming
// `req` write it to the `pReq` request.
//
req.on('readable', function () {
if (!errState) {
var bytes = req.read();

if (draining) {
if (buffer) { return buffer.push(bytes) }
buffer = [bytes];
return;
}

if (false === pReq.write(bytes)) {
draining = true;
}
}
});

req.on('drain', function () {
draining = false;
if (buffer.length) {
for (var i = 0; i < buffer.length; i++) {
//
// Remark: Should we check to see if `.write()`
// returns false here?
//
res.write(buffer[i]);
}

pBuffer.length = 0;
}
});

//
// When the incoming `req` ends, end the corresponding `pReq`
// request unless we have entered an error state.
//
req.on('end', function () {
if (!errState) {
pReq.end();
}
});

//Aborts pReq if client aborts the connection.
req.on('close', function () {
if (!errState) {

0 comments on commit 27d2359

Please sign in to comment.
You can’t perform that action at this time.