Skip to content

Commit

Permalink
[minor] s/function(/function (/ s/){/) {/
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Mar 9, 2013
1 parent 440013c commit 9cecd97
Show file tree
Hide file tree
Showing 32 changed files with 163 additions and 163 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ var server = httpProxy.createServer(function (req, res, proxy) {
});
});

server.proxy.on('end', function() {
server.proxy.on('end', function () {
console.log("The request was proxied.");
});

Expand Down Expand Up @@ -325,7 +325,7 @@ var certs = {
//
var options = {
https: {
SNICallback: function(hostname){
SNICallback: function (hostname) {
return certs[hostname];
}
},
Expand Down Expand Up @@ -424,8 +424,8 @@ var server = httpProxy.createServer(
options
);

server.listen(port, function() { ... });
server.on('upgrade', function(req, socket, head) {
server.listen(port, function () { ... });
server.on('upgrade', function (req, socket, head) {
server.proxy.proxyWebSocketRequest(req, socket, head);
});
```
Expand Down Expand Up @@ -453,7 +453,7 @@ var server = http.createServer(function (req, res) {
proxy.proxyRequest(req, res);
});

server.on('upgrade', function(req, socket, head) {
server.on('upgrade', function (req, socket, head) {
//
// Proxy websocket requests too
//
Expand All @@ -478,7 +478,7 @@ var server = httpProxy.createServer(function (req, res, proxy) {
});
})

server.on('upgrade', function(req, socket, head) {
server.on('upgrade', function (req, socket, head) {
//
// Put your custom server logic here
//
Expand Down
2 changes: 1 addition & 1 deletion examples/balancer/simple-balancer-with-websockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var server = http.createServer(function (req, res) {
// Get the 'next' proxy and send the upgrade request
//

server.on('upgrade', function(req, socket, head) {
server.on('upgrade', function (req, socket, head) {
nextProxy().proxyWebSocketRequest(req, socket, head);
});

Expand Down
4 changes: 2 additions & 2 deletions examples/helpers/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ Store.prototype = {
res.end()
}
var url = req.url.split('?').shift()
if(url === '/') {
if (url === '/') {
console.log('get index')
return send(Object.keys(store.store))
} else if(req.method == 'GET') {
} else if (req.method == 'GET') {
var obj = store.get (url)
send(obj || {error: 'not_found', url: url}, obj ? 200 : 404)
} else {
Expand Down
2 changes: 1 addition & 1 deletion examples/http/latent-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var util = require('util'),
//
httpProxy.createServer(function (req, res, proxy) {
var buffer = httpProxy.buffer(req);
setTimeout(function() {
setTimeout(function () {
proxy.proxyRequest(req, res, {
port: 9000,
host: 'localhost',
Expand Down
2 changes: 1 addition & 1 deletion examples/http/standalone-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var util = require('util'),
var proxy = new httpProxy.RoutingProxy();
http.createServer(function (req, res) {
var buffer = httpProxy.buffer(req);
setTimeout(function() {
setTimeout(function () {
proxy.proxyRequest(req, res, {
port: 9000,
host: 'localhost',
Expand Down
2 changes: 1 addition & 1 deletion lib/node-http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ exports.createServer = function () {
// __events will be lost.__
//
// var buffer = httpProxy.buffer(req);
// fs.readFile(path, function(){
// fs.readFile(path, function () {
// httpProxy.proxyRequest(req, res, host, port, buffer);
// });
//
Expand Down
18 changes: 9 additions & 9 deletions lib/node-http-proxy/http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,23 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
// * `x-forwarded-port`: Port of the original request.
//
if (this.enable.xforward && req.connection && req.socket) {
if (req.headers['x-forwarded-for']){
if (req.headers['x-forwarded-for']) {
var addressToAppend = "," + req.connection.remoteAddress || req.socket.remoteAddress;
req.headers['x-forwarded-for'] += addressToAppend;
}
else {
req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.socket.remoteAddress;
}

if (req.headers['x-forwarded-port']){
if (req.headers['x-forwarded-port']) {
var portToAppend = "," + req.connection.remotePort || req.socket.remotePort;
req.headers['x-forwarded-port'] += portToAppend;
}
else {
req.headers['x-forwarded-port'] = req.connection.remotePort || req.socket.remotePort;
}

if (req.headers['x-forwarded-proto']){
if (req.headers['x-forwarded-proto']) {
var protoToAppend = "," + getProto(req);
req.headers['x-forwarded-proto'] += protoToAppend;
}
Expand Down Expand Up @@ -302,7 +302,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
});

// Set the headers of the client response
Object.keys(response.headers).forEach(function(key){
Object.keys(response.headers).forEach(function (key) {
res.setHeader(key, response.headers[key]);
});
res.writeHead(response.statusCode);
Expand Down Expand Up @@ -438,23 +438,23 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
// * `x-forwarded-port`: Port of the original request.
//
if (this.enable.xforward && req.connection) {
if (req.headers['x-forwarded-for']){
if (req.headers['x-forwarded-for']) {
var addressToAppend = "," + req.connection.remoteAddress || socket.remoteAddress;
req.headers['x-forwarded-for'] += addressToAppend;
}
else {
req.headers['x-forwarded-for'] = req.connection.remoteAddress || socket.remoteAddress;
}

if (req.headers['x-forwarded-port']){
if (req.headers['x-forwarded-port']) {
var portToAppend = "," + req.connection.remotePort || socket.remotePort;
req.headers['x-forwarded-port'] += portToAppend;
}
else {
req.headers['x-forwarded-port'] = req.connection.remotePort || socket.remotePort;
}

if (req.headers['x-forwarded-proto']){
if (req.headers['x-forwarded-proto']) {
var protoToAppend = "," + (req.connection.pair ? 'wss' : 'ws');
req.headers['x-forwarded-proto'] += protoToAppend;
}
Expand Down Expand Up @@ -577,7 +577,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
// If the incoming `proxySocket` socket closes, then
// detach all event listeners.
//
listeners.onIncomingClose = function() {
listeners.onIncomingClose = function () {
reverseProxy.incoming.socket.destroy();
detach();

Expand All @@ -589,7 +589,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
// If the `reverseProxy` socket closes, then detach all
// event listeners.
//
listeners.onOutgoingClose = function() {
listeners.onOutgoingClose = function () {
proxySocket.destroy();
detach();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/node-http-proxy/routing-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ RoutingProxy.prototype.add = function (options) {
'websocket:end',
'websocket:incoming',
'websocket:outgoing'
].forEach(function(event) {
].forEach(function (event) {
this.proxies[key].on(event, this.emit.bind(this, event));
}, this);
};
Expand Down
16 changes: 8 additions & 8 deletions test/core/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ function protoCtrChain(o) {
return result.join();
}

exports.indirectInstanceOf = function(obj, cls) {
exports.indirectInstanceOf = function (obj, cls) {
if (obj instanceof cls) { return true; }
var clsChain = protoCtrChain(cls.prototype);
var objChain = protoCtrChain(obj);
return objChain.slice(-clsChain.length) === clsChain;
};


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


exports.spawnPwd = function(options) {
exports.spawnPwd = function (options) {
var spawn = require('child_process').spawn;

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

process.on('exit', function() {
process.on('exit', function () {
if (!exports.globalCheck) return;
var knownGlobals = [setTimeout,
setInterval,
Expand Down Expand Up @@ -152,11 +152,11 @@ var mustCallChecks = [];


function runCallChecks() {
var failed = mustCallChecks.filter(function(context) {
var failed = mustCallChecks.filter(function (context) {
return context.actual !== context.expected;
});

failed.forEach(function(context) {
failed.forEach(function (context) {
console.log('Mismatched %s function calls. Expected %d, actual %d.',
context.name,
context.expected,
Expand All @@ -168,7 +168,7 @@ function runCallChecks() {
}


exports.mustCall = function(fn, expected) {
exports.mustCall = function (fn, expected) {
if (typeof expected !== 'number') expected = 1;

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

mustCallChecks.push(context);

return function() {
return function () {
context.actual++;
return fn.apply(this, arguments);
};
Expand Down
10 changes: 5 additions & 5 deletions test/core/pummel/test-http-upload-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ var common = require('../common'),
server = http.createServer(),
connections = 0;

server.on('request', function(req, res) {
server.on('request', function (req, res) {
req.socket.setTimeout(1000);
req.socket.on('timeout', function() {
req.socket.on('timeout', function () {
throw new Error('Unexpected timeout');
});
req.on('end', function() {
req.on('end', function () {
connections--;
res.writeHead(200);
res.end('done\n');
Expand All @@ -43,11 +43,11 @@ server.on('request', function(req, res) {
});
});

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

setTimeout(function() {
setTimeout(function () {
var request = http.request({
port: common.PROXY_PORT,
method: 'POST',
Expand Down
14 changes: 7 additions & 7 deletions test/core/simple/test-http-chunked.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,31 @@ var UTF8_STRING = '南越国是前203年至前111年存在于岭南地区的一
'采用封建制和郡县制并存的制度,它的建立保证了秦末乱世岭南地区社会秩序的稳定,' +
'有效的改善了岭南地区落后的政治、经济现状。';

var server = http.createServer(function(req, res) {
var server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain; charset=utf8'});
res.end(UTF8_STRING, 'utf8');
});
server.listen(common.PORT, function() {
server.listen(common.PORT, function () {
var data = '';
var get = http.get({
path: '/',
host: 'localhost',
port: common.PROXY_PORT
}, function(x) {
}, function (x) {
x.setEncoding('utf8');
x.on('data', function(c) {data += c});
x.on('error', function(e) {
x.on('data', function (c) {data += c});
x.on('error', function (e) {
throw e;
});
x.on('end', function() {
x.on('end', function () {
assert.equal('string', typeof data);
console.log('here is the response:');
assert.equal(UTF8_STRING, data);
console.log(data);
server.close();
});
});
get.on('error', function(e) {throw e});
get.on('error', function (e) {throw e});
get.end();

});
14 changes: 7 additions & 7 deletions test/core/simple/test-http-client-abort.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ var http = require('http');

var clientAborts = 0;

var server = http.Server(function(req, res) {
var server = http.Server(function (req, res) {
console.log('Got connection');
res.writeHead(200);
res.write('Working on it...');

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

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

server.listen(common.PORT, function() {
server.listen(common.PORT, function () {
console.log('Server listening.');

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

if (++responses == N) {
console.log('All clients connected, destroying.');
requests.forEach(function(outReq) {
requests.forEach(function (outReq) {
console.log('abort');
outReq.abort();
});
Expand All @@ -75,6 +75,6 @@ server.listen(common.PORT, function() {
}
});

process.on('exit', function() {
process.on('exit', function () {
assert.equal(N, clientAborts);
});
8 changes: 4 additions & 4 deletions test/core/simple/test-http-client-abort2.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ var common = require('../common');
var assert = require('assert');
var http = require('http');

var server = http.createServer(function(req, res) {
var server = http.createServer(function (req, res) {
res.end('Hello');
});

server.listen(common.PORT, function() {
var req = http.get({port: common.PROXY_PORT}, function(res) {
res.on('data', function(data) {
server.listen(common.PORT, function () {
var req = http.get({port: common.PROXY_PORT}, function (res) {
res.on('data', function (data) {
req.abort();
server.close();
});
Expand Down
Loading

0 comments on commit 9cecd97

Please sign in to comment.