nodejitsu/node-http-proxy — Issue #184: proxy to a 302 redirect url fail to send response.
Author: wuhaocn2008
Created: 2012-01-31 03:38:36+00:00
State: open

I try to proxy a request to
"http://ptlogin2.qq.com/jump?ptlang=2052&clientuin=304290615&clientkey=0D399336F7C4F553C468779FC21FEC92B77EEE1F3D766C61BC3F3B19AD65E070&u1=http%3A%2F%2Fuser.qzone.qq.com%2F573692919" which actually send a "302 Found" status code, but the proxy failed to send any response.

my source code:
var http = require('http'),
httpProxy = require('http-proxy'),
url = require('url');
//
// Create your proxy server
//
httpProxy.createServer(function (req, res, proxy) {
//
// Buffer the request so that `data` and `end` events
// are not lost during async operation(s).
//
var buffer = httpProxy.buffer(req);
var parsed_url = url.parse(req.url);
var host = "localhost";
var port = 8001;
if(typeof(parsed_url.host)=='undefined') {
} else {
port = parsed_url.host.split(':');
host = parsed_url.hostname;
if(port[1]) {
port = port[1];
}else{
port = 80;
}
}
//setTimeout(function () {
proxy.proxyRequest(req, res, {
'host': host,
'port': port,
});
//}, 2000);
}).listen(8000);