Skip to content

Commit 7fc39d7

Browse files
committed
[minor] Strip trailing whitespace.
1 parent 59b71c0 commit 7fc39d7

File tree

4 files changed

+43
-43
lines changed

4 files changed

+43
-43
lines changed

lib/node-http-proxy.js

+31-31
Original file line numberDiff line numberDiff line change
@@ -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
//
224224
exports.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
//
370370
exports._getProtocol = function _getProtocol (options) {
371371
return options.https ? https : http;
@@ -381,7 +381,7 @@ exports._getProtocol = function _getProtocol (options) {
381381
//
382382
exports._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]) {

lib/node-http-proxy/http-proxy.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
239239
if (this.changeOrigin) {
240240
outgoing.headers.host = this.target.host + ':' + this.target.port;
241241
}
242-
242+
243243
//
244244
// Open new HTTP request to internal resource with will act
245245
// as a reverse proxy pass
@@ -366,7 +366,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
366366
socket.setTimeout(self.timeout);
367367
}
368368
});
369-
369+
370370
//
371371
// Handle 'error' events from the `req` (e.g. `Parse Error`).
372372
//
@@ -448,7 +448,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, upgradeHead,
448448
CRLF = '\r\n',
449449
//copy upgradeHead to avoid retention of large slab buffers used in node core
450450
head = new Buffer(upgradeHead.length);
451-
upgradeHead.copy(head);
451+
upgradeHead.copy(head);
452452

453453
//
454454
// WebSocket requests must have the `GET` method and
@@ -615,16 +615,16 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, upgradeHead,
615615
detach();
616616

617617
// Emit the `end` event now that we have completed proxying
618-
self.emit('websocket:end', req, socket, head);
618+
self.emit('websocket:end', req, socket, head);
619619
}
620620

621621
//
622622
// If the `reverseProxy` socket closes, then detach all
623623
// event listeners.
624-
//
624+
//
625625
listeners.onOutgoingClose = function () {
626626
proxySocket.destroy();
627-
detach();
627+
detach();
628628
}
629629

630630
proxySocket.on('end', listeners.onIncomingClose);
@@ -698,7 +698,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, upgradeHead,
698698
socket: socket,
699699
head: head
700700
};
701-
701+
702702
//
703703
// Here we set the handshake `headers` and `statusCode` data to the outgoing
704704
// request so that we can reuse this data later.
@@ -724,7 +724,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, upgradeHead,
724724
headers: res.headers,
725725
statusCode: res.statusCode,
726726
}
727-
727+
728728
//
729729
// Prepare the socket for the reverseProxy request and begin to
730730
// stream data between the two sockets. Here it is important to
@@ -756,7 +756,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, upgradeHead,
756756

757757
headers = headers.concat('', '').join('\r\n');
758758
}
759-
759+
760760
//
761761
// Ok, kind of harmfull part of code. Socket.IO sends a hash
762762
// at the end of handshake if protocol === 76, but we need

lib/node-http-proxy/proxy-table.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ ProxyTable.prototype.getProxyLocation = function (req) {
213213
var target = req.url;
214214
for (var i in this.routes) {
215215
var route = this.routes[i];
216-
//
216+
//
217217
// If we are matching pathname only, we remove the matched pattern.
218-
//
218+
//
219219
// IE /wiki/heartbeat
220220
// is redirected to
221221
// /heartbeat

lib/node-http-proxy/routing-proxy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ RoutingProxy.prototype.close = function () {
178178
//
179179
RoutingProxy.prototype.proxyRequest = function (req, res, options) {
180180
options = options || {};
181-
181+
182182
var location;
183183

184184
//

0 commit comments

Comments
 (0)