Skip to content

Commit babdf53

Browse files
committedOct 21, 2013
Revert "[fix] fixed options and server reference to can access them from passes functions"
This reverts commit 90fb01d.
1 parent 2bf20d6 commit babdf53

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed
 

‎lib/http-proxy/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function createRightProxy(type) {
7373
* refer to the connection socket
7474
* pass(req, socket, options, head)
7575
*/
76-
if(passes[i].call(this, req, res, head, cbl)) { // passes can return a truthy value to halt the loop
76+
if(passes[i](req, res, cbl ? false : this, head, cbl)) { // passes can return a truthy value to halt the loop
7777
break;
7878
}
7979
}

‎lib/http-proxy/passes/web-incoming.js

+13-18
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ web_o = Object.keys(web_o).map(function(pass) {
2323
*
2424
* @param {ClientRequest} Req Request object
2525
* @param {IncomingMessage} Res Response object
26+
* @param {Object} Options Config object passed to the proxy
2627
*
2728
* @api private
2829
*/
2930

30-
function deleteLength(req, res) {
31-
// Now the options are stored on this
32-
var options = this.options;
31+
function deleteLength(req, res, options) {
3332
if(req.method === 'DELETE' && !req.headers['content-length']) {
3433
req.headers['content-length'] = '0';
3534
}
@@ -40,13 +39,12 @@ web_o = Object.keys(web_o).map(function(pass) {
4039
*
4140
* @param {ClientRequest} Req Request object
4241
* @param {IncomingMessage} Res Response object
42+
* @param {Object} Options Config object passed to the proxy
4343
*
4444
* @api private
4545
*/
4646

47-
function timeout(req, res) {
48-
// Now the options are stored on this
49-
var options = this.options;
47+
function timeout(req, res, options) {
5048
if(options.timeout) {
5149
req.socket.setTimeout(options.timeout);
5250
}
@@ -57,13 +55,12 @@ web_o = Object.keys(web_o).map(function(pass) {
5755
*
5856
* @param {ClientRequest} Req Request object
5957
* @param {IncomingMessage} Res Response object
58+
* @param {Object} Options Config object passed to the proxy
6059
*
6160
* @api private
6261
*/
6362

64-
function XHeaders(req, res) {
65-
// Now the options are stored on this
66-
var options = this.options;
63+
function XHeaders(req, res, options) {
6764
if(!options.xfwd) return;
6865

6966
var values = {
@@ -87,26 +84,24 @@ web_o = Object.keys(web_o).map(function(pass) {
8784
*
8885
* @param {ClientRequest} Req Request object
8986
* @param {IncomingMessage} Res Response object
87+
* @param {Object} Options Config object passed to the proxy
9088
*
9189
* @api private
9290
*/
9391

94-
function stream(req, res, head, clb) {
95-
var server = this;
96-
// Now the options are stored on this
97-
var options = this.options;
98-
if(options.forward) {
92+
function stream(req, res, server, _, clb) {
93+
if(server.options.forward) {
9994
// If forward enable, so just pipe the request
100-
var forwardReq = (options.forward.protocol === 'https:' ? https : http).request(
101-
common.setupOutgoing(options.ssl || {}, options, req, 'forward')
95+
var forwardReq = (server.options.forward.protocol === 'https:' ? https : http).request(
96+
common.setupOutgoing(server.options.ssl || {}, server.options, req, 'forward')
10297
);
10398
req.pipe(forwardReq);
10499
return res.end();
105100
}
106101

107102
// Request initalization
108-
var proxyReq = (options.target.protocol === 'https:' ? https : http).request(
109-
common.setupOutgoing(options.ssl || {}, options, req)
103+
var proxyReq = (server.options.target.protocol === 'https:' ? https : http).request(
104+
common.setupOutgoing(server.options.ssl || {}, server.options, req)
110105
);
111106

112107
// Error Handler

0 commit comments

Comments
 (0)
Please sign in to comment.