Merge pull request #4 from alexyan/master

res.pipe(userRes,{end:false});
This commit is contained in:
想当当 2014-08-27 09:03:35 +08:00
commit d10dcd24d7

View File

@ -114,17 +114,13 @@ function userRequestHandler(req,userRes){
var proxyReq = (ifHttps ? https : http).request(options, function(res) { var proxyReq = (ifHttps ? https : http).request(options, function(res) {
userRes.writeHead(res.statusCode,mergeCORSHeader(req.headers,res.headers)); userRes.writeHead(res.statusCode,mergeCORSHeader(req.headers,res.headers));
if(callback){
res.on('data',function(chunk){ res.pipe(userRes,{end:false});
userRes.write(chunk); res.on('end',function(){
}); if(callback)callback(userRes);
res.on('end',function(){ userRes.end();
callback(userRes); });
userRes.end();
});
}else{
res.pipe(userRes);
}
}); });
proxyReq.on("error",function(e){ proxyReq.on("error",function(e){