Skip to content

Instantly share code, notes, and snippets.

@A
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save A/8790023 to your computer and use it in GitHub Desktop.
Save A/8790023 to your computer and use it in GitHub Desktop.
'use strict';
var http = require('http');
var app = http.createServer(function (req, res) {
if ('/foo' === req.url) {
setTimeout(function() {
res.writeHead(200);
res.write('foo');
res.end();
}, 500);
}
if ('/bar' === req.url) {
var options = {
host: '127.0.0.1',
port: 3000,
path: '/foo',
method: 'GET'
};
var request = http.request(options, function(result) {
(result).pipe(res);
});
request.end();
}
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment