@@ -82,7 +82,7 @@ exports.createServer = function () {
8282 case 'function' : callback = arg ; handlers . push ( callback ) ; break ;
8383 } ;
8484 } ) ;
85-
85+
8686 //
8787 // Helper function to create intelligent error message(s)
8888 // for the very liberal arguments parsing performed by
@@ -91,32 +91,32 @@ exports.createServer = function () {
9191 function validArguments ( ) {
9292 var conditions = {
9393 'port and host' : function ( ) {
94- return port && host ;
94+ return port && host ;
9595 } ,
9696 'options.target or options.router' : function ( ) {
97- return options && ( options . router ||
97+ return options && ( options . router ||
9898 ( options . target && options . target . host && options . target . port ) ) ;
9999 } ,
100100 'or proxy handlers' : function ( ) {
101101 return handlers && handlers . length ;
102102 }
103103 }
104-
104+
105105 var missing = Object . keys ( conditions ) . filter ( function ( name ) {
106106 return ! conditions [ name ] ( ) ;
107107 } ) ;
108-
108+
109109 if ( missing . length === 3 ) {
110110 message = 'Cannot proxy without ' + missing . join ( ', ' ) ;
111111 return false ;
112112 }
113-
113+
114114 return true ;
115- }
116-
115+ }
116+
117117 if ( ! validArguments ( ) ) {
118118 //
119- // If `host`, `port` and `options` are all not passed (with valid
119+ // If `host`, `port` and `options` are all not passed (with valid
120120 // options) then this server is improperly configured.
121121 //
122122 throw new Error ( message ) ;
@@ -131,7 +131,7 @@ exports.createServer = function () {
131131 options . target = options . target || { } ;
132132 options . target . port = options . target . port || port ;
133133 options . target . host = options . target . host || host ;
134-
134+
135135 if ( options . target && options . target . host && options . target . port ) {
136136 //
137137 // If an explicit `host` and `port` combination has been passed
@@ -149,31 +149,31 @@ exports.createServer = function () {
149149 // we have to assume that this is a "go-anywhere" Proxy (i.e. a `RoutingProxy`).
150150 //
151151 proxy = new RoutingProxy ( options ) ;
152-
152+
153153 if ( options . router ) {
154154 //
155- // If a routing table has been supplied than we assume
155+ // If a routing table has been supplied than we assume
156156 // the user intends us to add the "proxy" middleware layer
157- // for them
157+ // for them
158158 //
159159 handlers . push ( function ( req , res ) {
160160 proxy . proxyRequest ( req , res ) ;
161161 } ) ;
162-
162+
163163 proxy . on ( 'routes' , function ( routes ) {
164164 server . emit ( 'routes' , routes ) ;
165165 } ) ;
166- }
166+ }
167167 }
168-
168+
169169 //
170170 // Create the `http[s].Server` instance which will use
171171 // an instance of `httpProxy.HttpProxy`.
172172 //
173- handler = handlers . length > 1
173+ handler = handlers . length > 1
174174 ? exports . stack ( handlers , proxy )
175175 : function ( req , res ) { handlers [ 0 ] ( req , res , proxy ) } ;
176-
176+
177177 server = options . https
178178 ? https . createServer ( options . https , handler )
179179 : http . createServer ( handler ) ;
@@ -185,8 +185,8 @@ exports.createServer = function () {
185185 if ( ! callback ) {
186186 //
187187 // If an explicit callback has not been supplied then
188- // automagically proxy the request using the `HttpProxy`
189- // instance we have created.
188+ // automagically proxy the request using the `HttpProxy`
189+ // instance we have created.
190190 //
191191 server . on ( 'upgrade' , function ( req , socket , head ) {
192192 proxy . proxyWebSocketRequest ( req , socket , head ) ;
@@ -223,7 +223,7 @@ exports.createServer = function () {
223223//
224224exports . buffer = function ( obj ) {
225225 var events = [ ] ,
226- onData ,
226+ onData ,
227227 onEnd ;
228228
229229 obj . on ( 'data' , onData = function ( data , encoding ) {
@@ -244,7 +244,7 @@ exports.buffer = function (obj) {
244244 this . resume = function ( ) {
245245 console . error ( "Cannot resume buffer after destroying it." ) ;
246246 } ;
247-
247+
248248 onData = onEnd = events = obj = null ;
249249 } ,
250250 resume : function ( ) {
@@ -279,10 +279,10 @@ exports.setMaxSockets = function (value) {
279279//
280280// ### function stack (middlewares, proxy)
281281// #### @middlewares {Array} Array of functions to stack.
282- // #### @proxy {HttpProxy|RoutingProxy} Proxy instance to
282+ // #### @proxy {HttpProxy|RoutingProxy} Proxy instance to
283283// Iteratively build up a single handler to the `http.Server`
284284// `request` event (i.e. `function (req, res)`) by wrapping
285- // each middleware `layer` into a `child` middleware which
285+ // each middleware `layer` into a `child` middleware which
286286// is in invoked by the parent (i.e. predecessor in the Array).
287287//
288288// adapted from https://github.com/creationix/stack
@@ -296,17 +296,17 @@ exports.stack = function stack (middlewares, proxy) {
296296 if ( err ) {
297297 if ( res . _headerSent ) {
298298 res . destroy ( ) ;
299- }
299+ }
300300 else {
301301 res . statusCode = 500 ;
302302 res . setHeader ( 'Content-Type' , 'text/plain' ) ;
303303 res . end ( 'Internal Server Error' ) ;
304304 }
305-
305+
306306 console . error ( 'Error in middleware(s): %s' , err . stack ) ;
307307 return ;
308308 }
309-
309+
310310 if ( child ) {
311311 child ( req , res ) ;
312312 }
@@ -345,7 +345,7 @@ exports._getAgent = function _getAgent (options) {
345345 if ( ! options || ! options . host ) {
346346 throw new Error ( '`options.host` is required to create an Agent.' ) ;
347347 }
348-
348+
349349 if ( ! options . port ) {
350350 options . port = options . https ? 443 : 80 ;
351351 }
@@ -364,8 +364,8 @@ exports._getAgent = function _getAgent (options) {
364364//
365365// ### function _getProtocol (options)
366366// #### @options {Object} Options for the proxy target.
367- // Returns the appropriate node.js core protocol module (i.e. `http` or `https`)
368- // based on the `options` supplied.
367+ // Returns the appropriate node.js core protocol module (i.e. `http` or `https`)
368+ // based on the `options` supplied.
369369//
370370exports . _getProtocol = function _getProtocol ( options ) {
371371 return options . https ? https : http ;
@@ -381,7 +381,7 @@ exports._getProtocol = function _getProtocol (options) {
381381//
382382exports . _getBase = function _getBase ( options ) {
383383 var result = function ( ) { } ;
384-
384+
385385 if ( options . https && typeof options . https === 'object' ) {
386386 [ 'ca' , 'cert' , 'key' ] . forEach ( function ( key ) {
387387 if ( options . https [ key ] ) {
0 commit comments