node-rest-client
Advanced tools
Comparing version 1.8.0 to 2.0.0
@@ -12,2 +12,3 @@ var http = require('http'), | ||
var self = this; | ||
var connectManager = new ConnectManager(); | ||
@@ -24,3 +25,2 @@ self.options = options || {}, | ||
this.methods={}; | ||
@@ -253,6 +253,6 @@ // Client Request to be passed to ConnectManager and returned | ||
if (self.useProxy && self.useProxyTunnel){ | ||
ConnectManager.proxy(options,callback); | ||
connectManager.proxy(options,callback); | ||
}else{ | ||
// normal connection and direct proxy connections (no tunneling) | ||
ConnectManager.normal(options,callback); | ||
connectManager.normal(options,callback); | ||
} | ||
@@ -264,5 +264,5 @@ }, | ||
if (mimetypes.json && mimetypes.json instanceof Array && mimetypes.json.length > 0){ | ||
ConnectManager.jsonctype = mimetypes.json; | ||
connectManager.jsonctype = mimetypes.json; | ||
}else if (mimetypes.xml && mimetypes.xml instanceof Array && mimetypes.xml.length > 0){ | ||
ConnectManager.xmlctype = mimetypes.xml; | ||
connectManager.xmlctype = mimetypes.xml; | ||
} | ||
@@ -341,3 +341,3 @@ } | ||
// handle ConnectManager events | ||
ConnectManager.on('error',function(err){ | ||
connectManager.on('error',function(err){ | ||
self.emit('error',err); | ||
@@ -348,3 +348,3 @@ }); | ||
Util.mergeMimeTypes(self.mimetypes); | ||
debug("ConnectManager", ConnectManager); | ||
debug("ConnectManager", connectManager); | ||
@@ -354,6 +354,6 @@ }; | ||
var ConnectManager = { | ||
"xmlctype":["application/xml","application/xml;charset=utf-8"], | ||
"jsonctype":["application/json","application/json;charset=utf-8"], | ||
"isXML":function(content){ | ||
var ConnectManager = function() { | ||
this.xmlctype = ["application/xml","application/xml;charset=utf-8"]; | ||
this.jsonctype = ["application/json","application/json;charset=utf-8"], | ||
this.isXML = function(content){ | ||
var result = false; | ||
@@ -369,3 +369,3 @@ if (!content) return result; | ||
}, | ||
"isJSON":function(content){ | ||
this.isJSON = function(content){ | ||
var result = false; | ||
@@ -381,6 +381,6 @@ if (!content) return result; | ||
}, | ||
"isValidData":function(data){ | ||
this.isValidData = function(data){ | ||
return data !== undefined && (data.length !== undefined && data.length > 0); | ||
}, | ||
"configureRequest":function(req, config, clientRequest){ | ||
this.configureRequest = function(req, config, clientRequest){ | ||
@@ -401,3 +401,3 @@ if (config.timeout){ | ||
}, | ||
"configureResponse":function(res,config, clientRequest){ | ||
this.configureResponse = function(res,config, clientRequest){ | ||
if (config.timeout){ | ||
@@ -410,3 +410,3 @@ res.setTimeout(config.timeout, function(){ | ||
}, | ||
"handleEnd":function(res,buffer,callback){ | ||
this.handleEnd = function(res,buffer,callback){ | ||
@@ -435,3 +435,3 @@ var self = this, | ||
}, | ||
"handleResponse":function(res,data,callback){ | ||
this.handleResponse = function(res,data,callback){ | ||
var content = res.headers["content-type"] && res.headers["content-type"].replace(/ /g, ''); | ||
@@ -463,3 +463,3 @@ | ||
}, | ||
"prepareData":function(data){ | ||
this.prepareData = function(data){ | ||
var result; | ||
@@ -473,3 +473,3 @@ if ((data instanceof Buffer) || (typeof data !== 'object')){ | ||
}, | ||
"proxy":function(options, callback){ | ||
this.proxy = function(options, callback){ | ||
@@ -571,3 +571,3 @@ debug("proxy options",options.proxy); | ||
}, | ||
"normal":function(options, callback){ | ||
this.normal = function(options, callback){ | ||
@@ -655,3 +655,3 @@ var buffer = [], | ||
util.inherits(exports.Client, events.EventEmitter); | ||
util._extend(ConnectManager,events.EventEmitter.prototype); | ||
util.inherits(ConnectManager,events.EventEmitter); | ||
@@ -658,0 +658,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "node API REST client", | ||
"version": "1.8.0", | ||
"version": "2.0.0", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type":"git", |
43538
725