Last active
August 29, 2015 14:04
-
-
Save lakenen/4988b8812d3539e10d0e to your computer and use it in GitHub Desktop.
hyperquest issue
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') | |
, request = require('hyperquest') | |
var server = http.createServer(function (req, res) { | |
if (req.url === '/respond') { | |
res.end('ok') | |
return server.close() | |
} | |
proxy('http://localhost:11111/respond', req, res) | |
}).listen(11111) | |
request.get('http://localhost:11111/foo').pipe(process.stdout) | |
function proxy(uri, req, res) { | |
var r = request(uri, { | |
method: req.method | |
, headers: req.headers | |
}) | |
req.pipe(r).pipe(res) | |
r.on('error', function (err) { | |
console.error(err) | |
server.close() | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment