Comparing version 0.0.22 to 0.0.23
@@ -15,3 +15,2 @@ /* | ||
var urlencode = require('urlencode'); | ||
var http = require('http'); | ||
@@ -33,2 +32,5 @@ function HttpProtocol(){ | ||
} | ||
if (typeof config.rejectUnauthorized == 'undefined'){ | ||
config.rejectUnauthorized = true; | ||
} | ||
return config; | ||
@@ -56,4 +58,16 @@ }; | ||
}; | ||
var request; | ||
if (config.https){ | ||
request = require('https'); | ||
opt.key = config.key; | ||
opt.cert = config.cert; | ||
opt.rejectUnauthorized = config.rejectUnauthorized | ||
}else{ | ||
request = require('http'); | ||
} | ||
logger.trace('request start ' + JSON.stringify(opt)); | ||
var req = http.request(opt, function(res){ | ||
var req = request.request(opt, function(res){ | ||
if (res.statusCode >= 300) { | ||
@@ -60,0 +74,0 @@ req.emit('error', new Error('Server Status Error: ' + res.statusCode)); |
{ | ||
"name": "node-ral", | ||
"version": "0.0.22", | ||
"version": "0.0.23", | ||
"description": "a rpc client for node", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -133,2 +133,19 @@ /* | ||
}); | ||
it.only('should work well with https', function(done) { | ||
var get_test = require('./protocol/http_protocol_get_test.js'); | ||
//start a http server for get | ||
// var server = get_test.createServer(); | ||
var httpProtocol = new HttpProtocol(); | ||
var context = HttpProtocol.normalizeConfig(get_test.request_https); | ||
var stream = httpProtocol.talk(context, function(res){ | ||
res.on('data', function(data){ | ||
done(); | ||
}); | ||
}); | ||
stream.on('error', function(err){ | ||
console.log(err); | ||
err.should.be.null; | ||
}) | ||
}); | ||
}); | ||
@@ -135,0 +152,0 @@ |
@@ -53,2 +53,13 @@ /* | ||
module.exports.request_https = { | ||
https: true, | ||
method: 'GET', | ||
path: '/v2/?login', | ||
rejectUnauthorized: false, | ||
server : { | ||
host : 'passport.baidu.com', | ||
port: 443 | ||
} | ||
}; | ||
module.exports.createServer = function(){ | ||
@@ -55,0 +66,0 @@ return http.createServer(function (request, response) { |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
256440
6987
9