Skip to content

Instantly share code, notes, and snippets.

@fabiosantoscode
Created December 10, 2013 15:35
Show Gist options
  • Save fabiosantoscode/349a8d29d3bdf109c78c to your computer and use it in GitHub Desktop.
Save fabiosantoscode/349a8d29d3bdf109c78c to your computer and use it in GitHub Desktop.
reproducing a node-http-proxy bug, where the req.url is sent completely when a lot of servers will just use it in naive string concatenation
// npm install request
var httpProxy = require('http-proxy')
var http = require('http')
var request = require('request')
// This is the target server
http.createServer(function (req, res) {
console.log(' (target server): received the following req.url: %s', req.url)
res.end('naught!')
}).listen(64000);
// This is a node-http-proxy server
httpProxy.createServer(function (req, res, proxy) {
proxy.proxyRequest(req, res, {
host: 'localhost',
port: 64000
})
}).listen(64001)
// Let's talk
console.log("Let's talk to the target server, raw request")
request.get({
uri: 'http://localhost:64000' }, function (res) {
console.log("let's talk to the server through the proxy")
request.get({
uri: 'http://localhost:64000',
proxy: 'http://localhost:64001' }, function (res) {
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment