bugfix for https throttle

This commit is contained in:
OttoMao 2015-01-12 10:43:20 +08:00
parent c5ffd57e71
commit d5b6958dd9
2 changed files with 14 additions and 6 deletions

View File

@ -129,7 +129,7 @@ function userRequestHandler(req,userRes){
resHeader = util.lower_keys(resHeader);
// remove gzip related header, and ungzip the content
var ifServerGzipped = /gzip/i.test(resHeader['content-encoding']);
var ifServerGzipped = /gzip/i.test(resHeader['content-encoding']);
delete resHeader['content-encoding'];
delete resHeader['content-length'];
@ -295,14 +295,22 @@ function connectReqHandler(req, socket, head){
callback();
}
//connect
},function(callback){
try{
var conn = net.connect(proxyPort, proxyHost, function(){
socket.write('HTTP/' + req.httpVersion + ' 200 OK\r\n\r\n', 'UTF-8', function() {
conn.pipe(socket);
socket.pipe(conn);
socket.write('HTTP/' + req.httpVersion + ' 200 OK\r\n\r\n', 'UTF-8', function(){
//throttle for direct-foward https
if(GLOBAL._throttle && !shouldIntercept ){
var readable = conn.pipe(GLOBAL._throttle.throttle());
readable.pipe(socket);
socket.pipe(conn);
}else{
conn.pipe(socket);
socket.pipe(conn);
}
callback();
});

View File

@ -1,6 +1,6 @@
{
"name": "anyproxy",
"version": "3.0.2",
"version": "3.0.3",
"description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.",
"main": "proxy.js",
"bin": {