fix http req over https

This commit is contained in:
加里 2014-08-11 17:48:32 +08:00
parent 022902943f
commit df1bc9911a
5 changed files with 7 additions and 3 deletions

1
.gitignore vendored
View File

@ -6,6 +6,7 @@
.lock-wscript
.svn
.wafpickle-*
tmp.txt
CVS
npm-debug.log
cert/**/*.srl

1
bin.js
View File

@ -16,4 +16,5 @@ if(program.clear){
}else{
mainProxy.startServer(program.type,program.port, program.host);
}

View File

@ -2,8 +2,9 @@ var http = require("http"),
https = require("https");
function handler(req,userRes){
console.log(req);
var ifHttps = !!req.connection.encrypted;
var ifHttps = !!req.connection.encrypted && !/http:/.test(req.url);
var options = {
hostname : req.headers.host,

View File

@ -1,6 +1,6 @@
{
"name": "anyproxy",
"version": "0.1.0",
"version": "0.1.1",
"description": "https proxy over http",
"main": "proxy.js",
"bin": "bin.js",

View File

@ -29,7 +29,7 @@ function startServer(type, port, hostname){
//creat server
function(callback){
if(proxyType == T_TYPE_HTTPS){
httpsServerMgr.getCertificate(proxyHost,function(err,keyContent,crtContent){
certMgr.getCertificate(proxyHost,function(err,keyContent,crtContent){
if(err){
callback(err);
}else{
@ -44,6 +44,7 @@ function startServer(type, port, hostname){
}else{
httpProxyServer = http.createServer(requestHandler);
callback(null);
}
},