Comparing version 0.9.2 to 0.9.3
@@ -29,7 +29,7 @@ /** | ||
HttpProtocolBase.prototype.getName = function () { | ||
HttpProtocolBase.prototype.getName = function() { | ||
throw new Error('not implement'); | ||
}; | ||
HttpProtocolBase.prototype.normalizeConfig = HttpProtocolBase.normalizeConfig = function (config) { | ||
HttpProtocolBase.prototype.normalizeConfig = HttpProtocolBase.normalizeConfig = function(config) { | ||
config = Protocol.normalizeConfig(config); | ||
@@ -76,5 +76,4 @@ if (config.disableGzip === undefined) { | ||
HttpProtocolBase.prototype._request = function (config, callback) { | ||
var response = new ResponseStream(); | ||
var piped = false; | ||
HttpProtocolBase.prototype._prepareRequest = function(config) { | ||
config.requestPrepared = true; | ||
var path; | ||
@@ -85,2 +84,3 @@ | ||
}); | ||
if (query) { | ||
@@ -90,8 +90,6 @@ // didn't handle # situation since backend should not get a hash tag | ||
path = config.path + '?' + query; | ||
} | ||
else { | ||
} else { | ||
path = config.path + '&' + query; | ||
} | ||
} | ||
else { | ||
} else { | ||
path = config.path; | ||
@@ -141,6 +139,4 @@ } | ||
}; | ||
var request; | ||
if (config.https) { | ||
request = require('https'); | ||
opt.key = config.key; | ||
@@ -150,9 +146,6 @@ opt.cert = config.cert; | ||
opt.rejectUnauthorized = config.rejectUnauthorized; | ||
} | ||
else { | ||
} else { | ||
opt.protocol = 'http:'; | ||
request = require('http'); | ||
} | ||
var proxy = config.proxy || getProxyFromURI(opt); | ||
@@ -169,4 +162,3 @@ | ||
opt.agent = agent; | ||
} | ||
else { | ||
} else { | ||
opt.path = url.resolve(uri, path); | ||
@@ -178,5 +170,27 @@ var proxyUri = url.parse(proxy); | ||
} | ||
config.requestOpt = opt; | ||
return opt; | ||
}; | ||
HttpProtocolBase.prototype._request = function(config, callback) { | ||
var response = new ResponseStream(); | ||
var piped = false; | ||
var opt; | ||
if (!config.requestPrepared) { | ||
opt = this._prepareRequest(config); | ||
} else { | ||
opt = config.requestOpt; | ||
} | ||
var request; | ||
if (config.https) { | ||
request = require('https'); | ||
} else { | ||
request = require('http'); | ||
} | ||
logger.trace('request start ' + JSON.stringify(opt)); | ||
var req = request.request(opt, function (res) { | ||
var req = request.request(opt, function(res) { | ||
if (res.statusCode >= 300 && !config.ignoreStatusCode) { | ||
@@ -190,11 +204,11 @@ var statusCodeError = new Error('Server Status Error: ' + res.statusCode); | ||
// or, just use zlib.createUnzip() to handle both cases | ||
case 'gzip': | ||
res.pipe(zlib.createGunzip()).pipe(response); | ||
break; | ||
case 'deflate': | ||
res.pipe(zlib.createInflate()).pipe(response); | ||
break; | ||
default: | ||
res.pipe(response); | ||
break; | ||
case 'gzip': | ||
res.pipe(zlib.createGunzip()).pipe(response); | ||
break; | ||
case 'deflate': | ||
res.pipe(zlib.createInflate()).pipe(response); | ||
break; | ||
default: | ||
res.pipe(response); | ||
break; | ||
} | ||
@@ -211,10 +225,9 @@ callback && callback(response); | ||
req.end(); | ||
} | ||
else { | ||
} else { | ||
// auto end if no pipe | ||
setImmediate(function () { | ||
setImmediate(function() { | ||
piped || req.end(); | ||
}); | ||
} | ||
req.on('pipe', function () { | ||
req.on('pipe', function() { | ||
piped = true; | ||
@@ -233,3 +246,3 @@ }); | ||
ResponseStream.prototype.write = function (chunk) { | ||
ResponseStream.prototype.write = function(chunk) { | ||
// store the data | ||
@@ -239,3 +252,3 @@ this.chunks.push(chunk); | ||
ResponseStream.prototype.end = function () { | ||
ResponseStream.prototype.end = function() { | ||
var data = null; | ||
@@ -246,4 +259,3 @@ try { | ||
logger.trace('response end'); | ||
} | ||
catch (ex) { | ||
} catch (ex) { | ||
logger.trace('response failed errmsg=' + ex.message); | ||
@@ -250,0 +262,0 @@ this.emit('error', ex); |
{ | ||
"name": "node-ral", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"description": "a rpc client for node", | ||
@@ -35,3 +35,3 @@ "main": "index.js", | ||
"protobufjs": "5.0.1", | ||
"soap": "0.15.0", | ||
"soap": "0.13.0", | ||
"underscore": "1.8.3", | ||
@@ -38,0 +38,0 @@ "urlencode": "1.1.0", |
351525
10286
+ Addedsoap@0.13.0(transitive)
- Removedcompress@0.99.0(transitive)
- Removedejs@2.3.4(transitive)
- Removednode-uuid@1.4.8(transitive)
- Removedoptional@0.1.4(transitive)
- Removedsoap@0.15.0(transitive)
- Removedxml-crypto@0.8.5(transitive)
- Removedxpath.js@1.1.0(transitive)
Updatedsoap@0.13.0