Skip to content

Commit 9cecd97

Browse files
committed
[minor] s/function(/function (/ s/){/) {/
1 parent 440013c commit 9cecd97

32 files changed

+163
-163
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ var server = httpProxy.createServer(function (req, res, proxy) {
233233
});
234234
});
235235

236-
server.proxy.on('end', function() {
236+
server.proxy.on('end', function () {
237237
console.log("The request was proxied.");
238238
});
239239

@@ -325,7 +325,7 @@ var certs = {
325325
//
326326
var options = {
327327
https: {
328-
SNICallback: function(hostname){
328+
SNICallback: function (hostname) {
329329
return certs[hostname];
330330
}
331331
},
@@ -424,8 +424,8 @@ var server = httpProxy.createServer(
424424
options
425425
);
426426

427-
server.listen(port, function() { ... });
428-
server.on('upgrade', function(req, socket, head) {
427+
server.listen(port, function () { ... });
428+
server.on('upgrade', function (req, socket, head) {
429429
server.proxy.proxyWebSocketRequest(req, socket, head);
430430
});
431431
```
@@ -453,7 +453,7 @@ var server = http.createServer(function (req, res) {
453453
proxy.proxyRequest(req, res);
454454
});
455455

456-
server.on('upgrade', function(req, socket, head) {
456+
server.on('upgrade', function (req, socket, head) {
457457
//
458458
// Proxy websocket requests too
459459
//
@@ -478,7 +478,7 @@ var server = httpProxy.createServer(function (req, res, proxy) {
478478
});
479479
})
480480

481-
server.on('upgrade', function(req, socket, head) {
481+
server.on('upgrade', function (req, socket, head) {
482482
//
483483
// Put your custom server logic here
484484
//

examples/balancer/simple-balancer-with-websockets.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var server = http.createServer(function (req, res) {
5050
// Get the 'next' proxy and send the upgrade request
5151
//
5252

53-
server.on('upgrade', function(req, socket, head) {
53+
server.on('upgrade', function (req, socket, head) {
5454
nextProxy().proxyWebSocketRequest(req, socket, head);
5555
});
5656

examples/helpers/store.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ Store.prototype = {
3939
res.end()
4040
}
4141
var url = req.url.split('?').shift()
42-
if(url === '/') {
42+
if (url === '/') {
4343
console.log('get index')
4444
return send(Object.keys(store.store))
45-
} else if(req.method == 'GET') {
45+
} else if (req.method == 'GET') {
4646
var obj = store.get (url)
4747
send(obj || {error: 'not_found', url: url}, obj ? 200 : 404)
4848
} else {

examples/http/latent-proxy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var util = require('util'),
3434
//
3535
httpProxy.createServer(function (req, res, proxy) {
3636
var buffer = httpProxy.buffer(req);
37-
setTimeout(function() {
37+
setTimeout(function () {
3838
proxy.proxyRequest(req, res, {
3939
port: 9000,
4040
host: 'localhost',

examples/http/standalone-proxy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var util = require('util'),
3535
var proxy = new httpProxy.RoutingProxy();
3636
http.createServer(function (req, res) {
3737
var buffer = httpProxy.buffer(req);
38-
setTimeout(function() {
38+
setTimeout(function () {
3939
proxy.proxyRequest(req, res, {
4040
port: 9000,
4141
host: 'localhost',

lib/node-http-proxy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ exports.createServer = function () {
211211
// __events will be lost.__
212212
//
213213
// var buffer = httpProxy.buffer(req);
214-
// fs.readFile(path, function(){
214+
// fs.readFile(path, function () {
215215
// httpProxy.proxyRequest(req, res, host, port, buffer);
216216
// });
217217
//

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,23 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
134134
// * `x-forwarded-port`: Port of the original request.
135135
//
136136
if (this.enable.xforward && req.connection && req.socket) {
137-
if (req.headers['x-forwarded-for']){
137+
if (req.headers['x-forwarded-for']) {
138138
var addressToAppend = "," + req.connection.remoteAddress || req.socket.remoteAddress;
139139
req.headers['x-forwarded-for'] += addressToAppend;
140140
}
141141
else {
142142
req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.socket.remoteAddress;
143143
}
144144

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

153-
if (req.headers['x-forwarded-proto']){
153+
if (req.headers['x-forwarded-proto']) {
154154
var protoToAppend = "," + getProto(req);
155155
req.headers['x-forwarded-proto'] += protoToAppend;
156156
}
@@ -302,7 +302,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
302302
});
303303

304304
// Set the headers of the client response
305-
Object.keys(response.headers).forEach(function(key){
305+
Object.keys(response.headers).forEach(function (key) {
306306
res.setHeader(key, response.headers[key]);
307307
});
308308
res.writeHead(response.statusCode);
@@ -438,23 +438,23 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
438438
// * `x-forwarded-port`: Port of the original request.
439439
//
440440
if (this.enable.xforward && req.connection) {
441-
if (req.headers['x-forwarded-for']){
441+
if (req.headers['x-forwarded-for']) {
442442
var addressToAppend = "," + req.connection.remoteAddress || socket.remoteAddress;
443443
req.headers['x-forwarded-for'] += addressToAppend;
444444
}
445445
else {
446446
req.headers['x-forwarded-for'] = req.connection.remoteAddress || socket.remoteAddress;
447447
}
448448

449-
if (req.headers['x-forwarded-port']){
449+
if (req.headers['x-forwarded-port']) {
450450
var portToAppend = "," + req.connection.remotePort || socket.remotePort;
451451
req.headers['x-forwarded-port'] += portToAppend;
452452
}
453453
else {
454454
req.headers['x-forwarded-port'] = req.connection.remotePort || socket.remotePort;
455455
}
456456

457-
if (req.headers['x-forwarded-proto']){
457+
if (req.headers['x-forwarded-proto']) {
458458
var protoToAppend = "," + (req.connection.pair ? 'wss' : 'ws');
459459
req.headers['x-forwarded-proto'] += protoToAppend;
460460
}
@@ -577,7 +577,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
577577
// If the incoming `proxySocket` socket closes, then
578578
// detach all event listeners.
579579
//
580-
listeners.onIncomingClose = function() {
580+
listeners.onIncomingClose = function () {
581581
reverseProxy.incoming.socket.destroy();
582582
detach();
583583

@@ -589,7 +589,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
589589
// If the `reverseProxy` socket closes, then detach all
590590
// event listeners.
591591
//
592-
listeners.onOutgoingClose = function() {
592+
listeners.onOutgoingClose = function () {
593593
proxySocket.destroy();
594594
detach();
595595
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ RoutingProxy.prototype.add = function (options) {
120120
'websocket:end',
121121
'websocket:incoming',
122122
'websocket:outgoing'
123-
].forEach(function(event) {
123+
].forEach(function (event) {
124124
this.proxies[key].on(event, this.emit.bind(this, event));
125125
}, this);
126126
};

test/core/common.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ function protoCtrChain(o) {
4545
return result.join();
4646
}
4747

48-
exports.indirectInstanceOf = function(obj, cls) {
48+
exports.indirectInstanceOf = function (obj, cls) {
4949
if (obj instanceof cls) { return true; }
5050
var clsChain = protoCtrChain(cls.prototype);
5151
var objChain = protoCtrChain(obj);
5252
return objChain.slice(-clsChain.length) === clsChain;
5353
};
5454

5555

56-
exports.ddCommand = function(filename, kilobytes) {
56+
exports.ddCommand = function (filename, kilobytes) {
5757
if (process.platform === 'win32') {
5858
var p = path.resolve(exports.fixturesDir, 'create-file.js');
5959
return '"' + process.argv[0] + '" "' + p + '" "' +
@@ -64,7 +64,7 @@ exports.ddCommand = function(filename, kilobytes) {
6464
};
6565

6666

67-
exports.spawnPwd = function(options) {
67+
exports.spawnPwd = function (options) {
6868
var spawn = require('child_process').spawn;
6969

7070
if (process.platform === 'win32') {
@@ -78,7 +78,7 @@ exports.spawnPwd = function(options) {
7878
// Turn this off if the test should not check for global leaks.
7979
exports.globalCheck = true;
8080

81-
process.on('exit', function() {
81+
process.on('exit', function () {
8282
if (!exports.globalCheck) return;
8383
var knownGlobals = [setTimeout,
8484
setInterval,
@@ -152,11 +152,11 @@ var mustCallChecks = [];
152152

153153

154154
function runCallChecks() {
155-
var failed = mustCallChecks.filter(function(context) {
155+
var failed = mustCallChecks.filter(function (context) {
156156
return context.actual !== context.expected;
157157
});
158158

159-
failed.forEach(function(context) {
159+
failed.forEach(function (context) {
160160
console.log('Mismatched %s function calls. Expected %d, actual %d.',
161161
context.name,
162162
context.expected,
@@ -168,7 +168,7 @@ function runCallChecks() {
168168
}
169169

170170

171-
exports.mustCall = function(fn, expected) {
171+
exports.mustCall = function (fn, expected) {
172172
if (typeof expected !== 'number') expected = 1;
173173

174174
var context = {
@@ -183,7 +183,7 @@ exports.mustCall = function(fn, expected) {
183183

184184
mustCallChecks.push(context);
185185

186-
return function() {
186+
return function () {
187187
context.actual++;
188188
return fn.apply(this, arguments);
189189
};

test/core/pummel/test-http-upload-timeout.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ var common = require('../common'),
2828
server = http.createServer(),
2929
connections = 0;
3030

31-
server.on('request', function(req, res) {
31+
server.on('request', function (req, res) {
3232
req.socket.setTimeout(1000);
33-
req.socket.on('timeout', function() {
33+
req.socket.on('timeout', function () {
3434
throw new Error('Unexpected timeout');
3535
});
36-
req.on('end', function() {
36+
req.on('end', function () {
3737
connections--;
3838
res.writeHead(200);
3939
res.end('done\n');
@@ -43,11 +43,11 @@ server.on('request', function(req, res) {
4343
});
4444
});
4545

46-
server.listen(common.PORT, '127.0.0.1', function() {
46+
server.listen(common.PORT, '127.0.0.1', function () {
4747
for (var i = 0; i < 10; i++) {
4848
connections++;
4949

50-
setTimeout(function() {
50+
setTimeout(function () {
5151
var request = http.request({
5252
port: common.PROXY_PORT,
5353
method: 'POST',

test/core/simple/test-http-chunked.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,31 @@ var UTF8_STRING = '南越国是前203年至前111年存在于岭南地区的一
3333
'采用封建制和郡县制并存的制度,它的建立保证了秦末乱世岭南地区社会秩序的稳定,' +
3434
'有效的改善了岭南地区落后的政治、经济现状。';
3535

36-
var server = http.createServer(function(req, res) {
36+
var server = http.createServer(function (req, res) {
3737
res.writeHead(200, {'Content-Type': 'text/plain; charset=utf8'});
3838
res.end(UTF8_STRING, 'utf8');
3939
});
40-
server.listen(common.PORT, function() {
40+
server.listen(common.PORT, function () {
4141
var data = '';
4242
var get = http.get({
4343
path: '/',
4444
host: 'localhost',
4545
port: common.PROXY_PORT
46-
}, function(x) {
46+
}, function (x) {
4747
x.setEncoding('utf8');
48-
x.on('data', function(c) {data += c});
49-
x.on('error', function(e) {
48+
x.on('data', function (c) {data += c});
49+
x.on('error', function (e) {
5050
throw e;
5151
});
52-
x.on('end', function() {
52+
x.on('end', function () {
5353
assert.equal('string', typeof data);
5454
console.log('here is the response:');
5555
assert.equal(UTF8_STRING, data);
5656
console.log(data);
5757
server.close();
5858
});
5959
});
60-
get.on('error', function(e) {throw e});
60+
get.on('error', function (e) {throw e});
6161
get.end();
6262

6363
});

test/core/simple/test-http-client-abort.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ var http = require('http');
2525

2626
var clientAborts = 0;
2727

28-
var server = http.Server(function(req, res) {
28+
var server = http.Server(function (req, res) {
2929
console.log('Got connection');
3030
res.writeHead(200);
3131
res.write('Working on it...');
3232

3333
// I would expect an error event from req or res that the client aborted
3434
// before completing the HTTP request / response cycle, or maybe a new
3535
// event like "aborted" or something.
36-
req.on('aborted', function() {
36+
req.on('aborted', function () {
3737
clientAborts++;
3838
console.log('Got abort ' + clientAborts);
3939
if (clientAborts === N) {
@@ -44,7 +44,7 @@ var server = http.Server(function(req, res) {
4444

4545
// since there is already clientError, maybe that would be appropriate,
4646
// since "error" is magical
47-
req.on('clientError', function() {
47+
req.on('clientError', function () {
4848
console.log('Got clientError');
4949
});
5050
});
@@ -53,18 +53,18 @@ var responses = 0;
5353
var N = http.Agent.defaultMaxSockets - 1;
5454
var requests = [];
5555

56-
server.listen(common.PORT, function() {
56+
server.listen(common.PORT, function () {
5757
console.log('Server listening.');
5858

5959
for (var i = 0; i < N; i++) {
6060
console.log('Making client ' + i);
6161
var options = { port: common.PROXY_PORT, path: '/?id=' + i };
62-
var req = http.get(options, function(res) {
62+
var req = http.get(options, function (res) {
6363
console.log('Client response code ' + res.statusCode);
6464

6565
if (++responses == N) {
6666
console.log('All clients connected, destroying.');
67-
requests.forEach(function(outReq) {
67+
requests.forEach(function (outReq) {
6868
console.log('abort');
6969
outReq.abort();
7070
});
@@ -75,6 +75,6 @@ server.listen(common.PORT, function() {
7575
}
7676
});
7777

78-
process.on('exit', function() {
78+
process.on('exit', function () {
7979
assert.equal(N, clientAborts);
8080
});

test/core/simple/test-http-client-abort2.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ var common = require('../common');
2626
var assert = require('assert');
2727
var http = require('http');
2828

29-
var server = http.createServer(function(req, res) {
29+
var server = http.createServer(function (req, res) {
3030
res.end('Hello');
3131
});
3232

33-
server.listen(common.PORT, function() {
34-
var req = http.get({port: common.PROXY_PORT}, function(res) {
35-
res.on('data', function(data) {
33+
server.listen(common.PORT, function () {
34+
var req = http.get({port: common.PROXY_PORT}, function (res) {
35+
res.on('data', function (data) {
3636
req.abort();
3737
server.close();
3838
});

0 commit comments

Comments
 (0)