Skip to content

Instantly share code, notes, and snippets.

View syshen's full-sized avatar

Steven Shen syshen

View GitHub Profile
function hook(req, res, next) {
var _end = res.end;
res.end = function() {
// process something
res.end = _end;
res.end();
}
}
OutgoingMessage.prototype.end = function(data, encoding) {
if (this.finished) {
return false;
}
if (!this._header) {
this._implicitHeader();
}
if (data && !this._hasBody) {
debug('This type of response MUST NOT have a body. ' +
TypeError: Object #<Object> has no method '_implicitHeader'
at http.js:645:10
at ServerResponse.end (/Users/syshen/Codes/node/web/connect_server.js:13:9)
at Object.handleResponse [as handle] (/Users/syshen/Codes/node/web/connect_server.js:20:9)
at next (/Users/syshen/Codes/node/web/node_modules/connect/lib/http.js:201:15)
at Object.hook [as handle] (/Users/syshen/Codes/node/web/connect_server.js:15:5)
at next (/Users/syshen/Codes/node/web/node_modules/connect/lib/http.js:201:15)
at Object.query [as handle] (/Users/syshen/Codes/node/web/node_modules/connect/lib/middleware/query.js:38:5)
at next (/Users/syshen/Codes/node/web/node_modules/connect/lib/http.js:201:15)
at Object.cookieParser [as handle] (/Users/syshen/Codes/node/web/node_modules/connect/lib/middleware/cookieParser.js:44:5)
function hook(req, res, next) {
var _end = res.end;
res.end = function() {
// process something
_end();
}
}
function test1() {
this.name = "test1";
this.print = function() {
console.log(this.name);
}
}
function test2() {
this.name = "test2";
function parent() {
this.print = function() {};
this.hello = function() {};
}
function child() {
}
parent.call(child.prototype);
var c = new child();
c.print();
function test1() {
this.name = "test1";
this.print = function() {
console.log(this.name);
}
}
function test2() {
this.name = "test2";
}
function MyFunc() {
console.log(this);
}
MyFunc();
function MyClass() {
this.x = 123;
this.y = 456;
};
MyClass.prototype.show = function() {
console.log(this);
};
describe('Strategy in round robin', function() {
describe("with one proxy setting", function() {
basic_options["backends"] = [
{
host: "127.0.0.1",
port: 8001,
https: false
}
];
var proxy = new lbProxy.LoadBalancingProxy(basic_options);