Skip to content

Commit 04ce49c

Browse files
coderarityindexzero
authored andcommitted
Whitespace fixes.
1 parent 1cc1f90 commit 04ce49c

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

Diff for: lib/node-http-proxy/http-proxy.js

+50-50
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ var HttpProxy = exports.HttpProxy = function (options) {
5252
if (!options || !options.target) {
5353
throw new Error('Both `options` and `options.target` are required.');
5454
}
55-
55+
5656
events.EventEmitter.call(this);
57-
57+
5858
var self = this;
5959

6060
//
61-
// Setup basic proxying options:
62-
//
61+
// Setup basic proxying options:
62+
//
6363
// * forward {Object} Options for a forward-proxy (if-any)
6464
// * target {Object} Options for the **sole** proxy target of this instance
6565
//
@@ -69,23 +69,23 @@ var HttpProxy = exports.HttpProxy = function (options) {
6969
//
7070
// Setup the necessary instances instance variables for
7171
// the `target` and `forward` `host:port` combinations
72-
// used by this instance.
72+
// used by this instance.
7373
//
7474
// * agent {http[s].Agent} Agent to be used by this instance.
7575
// * protocol {http|https} Core node.js module to make requests with.
7676
// * base {Object} Base object to create when proxying containing any https settings.
77-
//
77+
//
7878
function setupProxy (key) {
7979
self[key].agent = httpProxy._getAgent(self[key]);
8080
self[key].protocol = httpProxy._getProtocol(self[key]);
81-
self[key].base = httpProxy._getBase(self[key]);
81+
self[key].base = httpProxy._getBase(self[key]);
8282
}
83-
83+
8484
setupProxy('target');
85-
if (this.forward) {
86-
setupProxy('forward');
85+
if (this.forward) {
86+
setupProxy('forward');
8787
}
88-
88+
8989
//
9090
// Setup opt-in features
9191
//
@@ -103,7 +103,7 @@ var HttpProxy = exports.HttpProxy = function (options) {
103103
//
104104
this.source = options.source || { host: 'localhost', port: 8000 };
105105
this.source.https = this.source.https || options.https;
106-
this.changeOrigin = options.changeOrigin || false;
106+
this.changeOrigin = options.changeOrigin || false;
107107
};
108108

109109
// Inherit from events.EventEmitter
@@ -116,14 +116,14 @@ util.inherits(HttpProxy, events.EventEmitter);
116116
// #### @buffer {Object} Result from `httpProxy.buffer(req)`
117117
//
118118
HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
119-
var self = this,
119+
var self = this,
120120
errState = false,
121121
outgoing = new(this.target.base),
122122
reverseProxy;
123123

124124
//
125125
// Add common proxy headers to the request so that they can
126-
// be availible to the proxy target server. If the proxy is
126+
// be availible to the proxy target server. If the proxy is
127127
// part of proxy chain it will append the address:
128128
//
129129
// * `x-forwarded-for`: IP Address of the original request
@@ -134,23 +134,23 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
134134
if (req.headers['x-forwarded-for']){
135135
var addressToAppend = "," + req.connection.remoteAddress || req.socket.remoteAddress;
136136
req.headers['x-forwarded-for'] += addressToAppend;
137-
}
137+
}
138138
else {
139139
req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.socket.remoteAddress;
140140
}
141141

142142
if (req.headers['x-forwarded-port']){
143143
var portToAppend = "," + req.connection.remotePort || req.socket.remotePort;
144144
req.headers['x-forwarded-port'] += portToAppend;
145-
}
145+
}
146146
else {
147147
req.headers['x-forwarded-port'] = req.connection.remotePort || req.socket.remotePort;
148148
}
149149

150150
if (req.headers['x-forwarded-proto']){
151151
var protoToAppend = "," + (req.connection.pair ? 'https' : 'http');
152152
req.headers['x-forwarded-proto'] += protoToAppend;
153-
}
153+
}
154154
else {
155155
req.headers['x-forwarded-proto'] = req.connection.pair ? 'https' : 'http';
156156
}
@@ -217,7 +217,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
217217
outgoing.headers = req.headers;
218218

219219
//
220-
// Open new HTTP request to internal resource with will act
220+
// Open new HTTP request to internal resource with will act
221221
// as a reverse proxy pass
222222
//
223223
reverseProxy = this.target.protocol.request(outgoing, function (response) {
@@ -286,10 +286,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
286286
ended = true
287287
if (!errState) {
288288
reverseProxy.removeListener('error', proxyError);
289-
289+
290290
try { res.end() }
291291
catch (ex) { console.error("res.end error: %s", ex.message) }
292-
292+
293293
// Emit the `end` event now that we have completed proxying
294294
self.emit('end', req, res);
295295
}
@@ -313,19 +313,19 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
313313
// `req` write it to the `reverseProxy` request.
314314
//
315315
req.on('data', function (chunk) {
316-
316+
317317
if (!errState) {
318318
var flushed = reverseProxy.write(chunk);
319319
if (!flushed) {
320320
req.pause();
321321
reverseProxy.once('drain', function () {
322-
try { req.resume() }
322+
try { req.resume() }
323323
catch (er) { console.error("req.resume error: %s", er.message) }
324324
});
325-
325+
326326
//
327327
// Force the `drain` event in 100ms if it hasn't
328-
// happened on its own.
328+
// happened on its own.
329329
//
330330
setTimeout(function () {
331331
reverseProxy.emit('drain');
@@ -367,7 +367,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
367367
// #### @socket {net.Socket} Socket for the underlying HTTP request
368368
// #### @head {string} Headers for the Websocket request.
369369
// #### @buffer {Object} Result from `httpProxy.buffer(req)`
370-
// Performs a WebSocket proxy operation to the location specified by
370+
// Performs a WebSocket proxy operation to the location specified by
371371
// `this.target`.
372372
//
373373
HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer) {
@@ -387,10 +387,10 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
387387
//
388388
return socket.destroy();
389389
}
390-
390+
391391
//
392392
// Add common proxy headers to the request so that they can
393-
// be availible to the proxy target server. If the proxy is
393+
// be availible to the proxy target server. If the proxy is
394394
// part of proxy chain it will append the address:
395395
//
396396
// * `x-forwarded-for`: IP Address of the original request
@@ -401,23 +401,23 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
401401
if (req.headers['x-forwarded-for']){
402402
var addressToAppend = "," + req.connection.remoteAddress || req.connection.socket.remoteAddress;
403403
req.headers['x-forwarded-for'] += addressToAppend;
404-
}
404+
}
405405
else {
406406
req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.connection.socket.remoteAddress;
407407
}
408408

409409
if (req.headers['x-forwarded-port']){
410410
var portToAppend = "," + req.connection.remotePort || req.connection.socket.remotePort;
411411
req.headers['x-forwarded-port'] += portToAppend;
412-
}
412+
}
413413
else {
414414
req.headers['x-forwarded-port'] = req.connection.remotePort || req.connection.socket.remotePort;
415415
}
416416

417417
if (req.headers['x-forwarded-proto']){
418418
var protoToAppend = "," + (req.connection.pair ? 'wss' : 'ws');
419419
req.headers['x-forwarded-proto'] += protoToAppend;
420-
}
420+
}
421421
else {
422422
req.headers['x-forwarded-proto'] = req.connection.pair ? 'wss' : 'ws';
423423
}
@@ -432,7 +432,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
432432
function _socket(socket, keepAlive) {
433433
socket.setTimeout(0);
434434
socket.setNoDelay(true);
435-
435+
436436
if (keepAlive) {
437437
if (socket.setKeepAlive) {
438438
socket.setKeepAlive(true, 0);
@@ -445,7 +445,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
445445
socket.setEncoding('utf8');
446446
}
447447
}
448-
448+
449449
//
450450
// Setup the incoming client socket.
451451
//
@@ -474,13 +474,13 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
474474
if (!flushed) {
475475
proxySocket.pause();
476476
reverseProxy.incoming.socket.once('drain', function () {
477-
try { proxySocket.resume() }
477+
try { proxySocket.resume() }
478478
catch (er) { console.error("proxySocket.resume error: %s", er.message) }
479479
});
480-
480+
481481
//
482482
// Force the `drain` event in 100ms if it hasn't
483-
// happened on its own.
483+
// happened on its own.
484484
//
485485
setTimeout(function () {
486486
reverseProxy.incoming.socket.emit('drain');
@@ -506,13 +506,13 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
506506
if (!flushed) {
507507
reverseProxy.incoming.socket.pause();
508508
proxySocket.once('drain', function () {
509-
try { reverseProxy.incoming.socket.resume() }
509+
try { reverseProxy.incoming.socket.resume() }
510510
catch (er) { console.error("reverseProxy.incoming.socket.resume error: %s", er.message) }
511511
});
512-
512+
513513
//
514514
// Force the `drain` event in 100ms if it hasn't
515-
// happened on its own.
515+
// happened on its own.
516516
//
517517
setTimeout(function () {
518518
proxySocket.emit('drain');
@@ -572,7 +572,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
572572
protocolName = this.target.https ? 'https' : 'http',
573573
portUri = getPort(this.source.port),
574574
remoteHost = this.target.host + portUri;
575-
575+
576576
//
577577
// Change headers (if requested).
578578
//
@@ -591,7 +591,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
591591
outgoing.path = req.url;
592592
outgoing.headers = req.headers;
593593
outgoing.agent = agent;
594-
594+
595595
var reverseProxy = this.target.protocol.request(outgoing);
596596

597597
//
@@ -678,13 +678,13 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
678678
if (!flushed) {
679679
revSocket.pause();
680680
socket.once('drain', function () {
681-
try { revSocket.resume() }
681+
try { revSocket.resume() }
682682
catch (er) { console.error("reverseProxy.socket.resume error: %s", er.message) }
683683
});
684684

685685
//
686686
// Force the `drain` event in 100ms if it hasn't
687-
// happened on its own.
687+
// happened on its own.
688688
//
689689
setTimeout(function () {
690690
socket.emit('drain');
@@ -693,7 +693,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
693693
}
694694
catch (ex) {
695695
//
696-
// Remove data listener on socket error because the
696+
// Remove data listener on socket error because the
697697
// 'handshake' has failed.
698698
//
699699
revSocket.removeListener('data', handshake);
@@ -714,8 +714,8 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
714714

715715
try {
716716
//
717-
// Attempt to write the upgrade-head to the reverseProxy
718-
// request. This is small, and there's only ever one of
717+
// Attempt to write the upgrade-head to the reverseProxy
718+
// request. This is small, and there's only ever one of
719719
// it; no need for pause/resume.
720720
//
721721
// XXX This is very wrong and should be fixed in node's core
@@ -763,7 +763,7 @@ HttpProxy.prototype.close = function () {
763763
// by `this.forward` ignoring errors and the subsequent response.
764764
//
765765
HttpProxy.prototype._forwardRequest = function (req) {
766-
var self = this,
766+
var self = this,
767767
outgoing = new(this.forward.base),
768768
forwardProxy;
769769

@@ -778,7 +778,7 @@ HttpProxy.prototype._forwardRequest = function (req) {
778778
outgoing.headers = req.headers;
779779

780780
//
781-
// Open new HTTP request to internal resource with will
781+
// Open new HTTP request to internal resource with will
782782
// act as a reverse proxy pass.
783783
//
784784
forwardProxy = this.forward.protocol.request(outgoing, function (response) {
@@ -805,13 +805,13 @@ HttpProxy.prototype._forwardRequest = function (req) {
805805
if (!flushed) {
806806
req.pause();
807807
forwardProxy.once('drain', function () {
808-
try { req.resume() }
808+
try { req.resume() }
809809
catch (er) { console.error("req.resume error: %s", er.message) }
810810
});
811811

812812
//
813813
// Force the `drain` event in 100ms if it hasn't
814-
// happened on its own.
814+
// happened on its own.
815815
//
816816
setTimeout(function () {
817817
forwardProxy.emit('drain');
@@ -820,7 +820,7 @@ HttpProxy.prototype._forwardRequest = function (req) {
820820
});
821821

822822
//
823-
// At the end of the client request, we are going to
823+
// At the end of the client request, we are going to
824824
// stop the proxied request
825825
//
826826
req.on('end', function () {

0 commit comments

Comments
 (0)