@@ -32,9 +32,9 @@ var util = require('util'),
32
32
maxSockets = 100 ;
33
33
34
34
//
35
- // ### Version 0.5.7 // 5/19/2011
35
+ // Expose version information through `pkginfo`.
36
36
//
37
- exports . version = [ 0 , 5 , 7 ] ;
37
+ require ( 'pkginfo' ) ( module , 'version' ) ;
38
38
39
39
//
40
40
// Track our own list of agents internal to `node-http-proxy`
@@ -113,30 +113,6 @@ exports.getMaxSockets = function () {
113
113
exports . setMaxSockets = function ( value ) {
114
114
maxSockets = value ;
115
115
} ;
116
- //
117
- // stack
118
- // adapted from https://github.com/creationix/stack
119
- //
120
-
121
- function stack ( middlewares , proxy ) {
122
- var handle ;
123
- middlewares . reverse ( ) . forEach ( function ( layer ) {
124
-
125
- var child = handle ;
126
- var next = function ( err ) {
127
- if ( err ) {
128
- throw err ;
129
- //return error(req, res, err);
130
- }
131
- child ( req , res ) ;
132
- }
133
- next . __proto__ = proxy ;
134
- handle = function ( req , res ) {
135
- layer ( req , res , next ) ;
136
- } ;
137
- } ) ;
138
- return handle ;
139
- }
140
116
141
117
//
142
118
// stack
@@ -185,6 +161,7 @@ exports.createServer = function () {
185
161
proxy , server ,
186
162
options = { } ,
187
163
middleware = [ ] ,
164
+ handler ,
188
165
silent ;
189
166
190
167
args . forEach ( function ( arg ) {
@@ -196,7 +173,7 @@ exports.createServer = function () {
196
173
} ;
197
174
} ) ;
198
175
199
- var proxy = new HttpProxy ( options ) ;
176
+ proxy = new HttpProxy ( options ) ;
200
177
201
178
if ( port && host ) {
202
179
//
@@ -232,7 +209,9 @@ exports.createServer = function () {
232
209
handler = callback = stack ( middleware , proxy ) ;
233
210
}
234
211
else if ( middleware . length ) {
235
- //do not use middleware code if it's not needed.
212
+ //
213
+ // Do not use middleware code if it's not needed.
214
+ //
236
215
var h = middleware [ 0 ] ;
237
216
handler = callback = function ( req , res ) { h ( req , res , proxy ) } ;
238
217
}
@@ -273,7 +252,6 @@ exports.createServer = function () {
273
252
// to the consumer of the server
274
253
//
275
254
server . proxy = proxy ;
276
-
277
255
return server ;
278
256
} ;
279
257
0 commit comments