This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http') | |
, https = require('https') | |
res.writeHead(200); | |
console.log(Object.getOwnPropertyNames(http)); | |
console.log(http) | |
http.request({ // establishing a tunnel | |
host: 'itgproxy', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('https').get({ host: 'github.com' }, function (bres) { | |
res.writeHead(bres.statusCode); | |
bres.pipe(res); | |
}).on('error', function (err) { | |
res.writeHead(500); | |
res.end('Error talking to backend: ' + err); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setTimeout(function () { | |
throw new Error('an exception'); | |
}, 1000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res.writeHead(200); | |
res.end('Hello, world!\n'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Before writeHead'); | |
res.writeHead(200); | |
console.log('Before write'); | |
res.write('Hello, '); | |
console.log('Before end'); | |
res.end('world!\n'); | |
console.log('After end'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var query = require('url').parse(req.url, true).query | |
var mongoUrl = query['db'] || 'mongodb://arr:[email protected]:10024/arr' | |
var filter = query['host'] ? { hosts: query['host'] } : {} | |
require('mongodb').connect(mongoUrl, function (err, db) { | |
if (notError(err)) | |
db.collection('apps', function (err, apps) { | |
if (notError(err)) | |
apps.find(filter).toArray(function (err, docs) { | |
if (notError(err)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request').defaults({ proxy: 'http://itgproxy:80' }) | |
request('http://www.google.com').pipe(res) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
http.Agent.foo = http.Agent.foo || 0; | |
http.Agent.foo++; | |
res.writeHead(200); | |
res.end('foo: ' + http.Agent.foo + '\n'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res.writeHead(200); | |
res.end('Hello, world!\n'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//'use strict'; | |
var n = function () { | |
console.log(new Error().stack) | |
console.log(arguments) | |
console.log(arguments.callee) | |
console.log(arguments.callee.caller) | |
console.log(Object.getOwnPropertyNames(arguments.callee.caller)) | |
console.log(arguments.callee.caller.prototype) | |
} |
OlderNewer