Skip to content

Commit

Permalink
[fix] remove old legacy code
Browse files Browse the repository at this point in the history
  • Loading branch information
yawnt committed Jun 12, 2013
1 parent 374eb93 commit 27d2359
Showing 1 changed file with 1 addition and 51 deletions.
52 changes: 1 addition & 51 deletions lib/node-http-proxy/http-proxy.js
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 27d2359

Please sign in to comment.