@@ -23,13 +23,12 @@ web_o = Object.keys(web_o).map(function(pass) {
23
23
*
24
24
* @param {ClientRequest } Req Request object
25
25
* @param {IncomingMessage} Res Response object
26
+ * @param {Object } Options Config object passed to the proxy
26
27
*
27
28
* @api private
28
29
*/
29
30
30
- function deleteLength ( req , res ) {
31
- // Now the options are stored on this
32
- var options = this . options ;
31
+ function deleteLength ( req , res , options ) {
33
32
if ( req . method === 'DELETE' && ! req . headers [ 'content-length' ] ) {
34
33
req . headers [ 'content-length' ] = '0' ;
35
34
}
@@ -40,13 +39,12 @@ web_o = Object.keys(web_o).map(function(pass) {
40
39
*
41
40
* @param {ClientRequest } Req Request object
42
41
* @param {IncomingMessage} Res Response object
42
+ * @param {Object } Options Config object passed to the proxy
43
43
*
44
44
* @api private
45
45
*/
46
46
47
- function timeout ( req , res ) {
48
- // Now the options are stored on this
49
- var options = this . options ;
47
+ function timeout ( req , res , options ) {
50
48
if ( options . timeout ) {
51
49
req . socket . setTimeout ( options . timeout ) ;
52
50
}
@@ -57,13 +55,12 @@ web_o = Object.keys(web_o).map(function(pass) {
57
55
*
58
56
* @param {ClientRequest } Req Request object
59
57
* @param {IncomingMessage} Res Response object
58
+ * @param {Object } Options Config object passed to the proxy
60
59
*
61
60
* @api private
62
61
*/
63
62
64
- function XHeaders ( req , res ) {
65
- // Now the options are stored on this
66
- var options = this . options ;
63
+ function XHeaders ( req , res , options ) {
67
64
if ( ! options . xfwd ) return ;
68
65
69
66
var values = {
@@ -87,26 +84,24 @@ web_o = Object.keys(web_o).map(function(pass) {
87
84
*
88
85
* @param {ClientRequest } Req Request object
89
86
* @param {IncomingMessage} Res Response object
87
+ * @param {Object } Options Config object passed to the proxy
90
88
*
91
89
* @api private
92
90
*/
93
91
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 ) {
99
94
// 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' )
102
97
) ;
103
98
req . pipe ( forwardReq ) ;
104
99
return res . end ( ) ;
105
100
}
106
101
107
102
// 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 )
110
105
) ;
111
106
112
107
// Error Handler
0 commit comments