lib/client.js
function Client(options, isSecure) {

  // Invokes with new if called without
  if (false === (this instanceof Client)) {
    return new Client(options, isSecure)
  }

  // If a string URI is passed in, converts to URI fields
  if (typeof options === 'string') {
    options = url.parse(options)
    options.host = options.hostname
    options.path = options.pathname
  }

  if (typeof options.url !== 'undefined') {
    var parsedUrl = url.parse(options.url);
    options.host = parsedUrl.hostname;
    options.path = parsedUrl.pathname;
    options.port = parsedUrl.port;
  }

  // Set the HTTP request headers
  var headers = {
    'User-Agent'     : 'NodeJS XML-RPC Client'
  , 'Content-Type'   : 'text/xml'
  , 'Accept'         : 'text/xml'
  , 'Accept-Charset' : 'UTF8'
  , 'Connection'     : 'Keep-Alive'
  }
  options.headers = options.headers || {}

  if (options.headers.Authorization == null &&
      options.basic_auth != null &&
      options.basic_auth.user != null &&
      options.basic_auth.pass != null)
  {
    var auth = options.basic_auth.user + ':' + options.basic_auth.pass
    options.headers['Authorization'] = 'Basic ' + new Buffer(auth).toString('base64')
  }

  for (var attribute in headers) {
    if (options.headers[attribute] === undefined) {
      options.headers[attribute] = headers[attribute]
    }
  }

  options.method = 'POST'
  this.options = options

  this.isSecure = isSecure
  this.headersProcessors = {
    processors: [],
    composeRequest: function(headers) {
      this.processors.forEach(function(p) {p.composeRequest(headers);})
    },
    parseResponse: function(headers) {
      this.processors.forEach(function(p) {p.parseResponse(headers);})
    }
  };
  if (options.cookies) {
    this.cookies = new Cookies();
    this.headersProcessors.processors.unshift(this.cookies);
  }
}
function Client(options, isSecure) {

  // Invokes with new if called without
  if (false === (this instanceof Client)) {
    return new Client(options, isSecure)
  }

  // If a string URI is passed in, converts to URI fields
  if (typeof options === 'string') {
    options = url.parse(options)
    options.host = options.hostname
    options.path = options.pathname
  }

  if (typeof options.url !== 'undefined') {
    var parsedUrl = url.parse(options.url);
    options.host = parsedUrl.hostname;
    options.path = parsedUrl.pathname;
    options.port = parsedUrl.port;
  }

  // Set the HTTP request headers
  var headers = {
    'User-Agent'     : 'NodeJS XML-RPC Client'
  , 'Content-Type'   : 'text/xml'
  , 'Accept'         : 'text/xml'
  , 'Accept-Charset' : 'UTF8'
  , 'Connection'     : 'Keep-Alive'
  }
  options.headers = options.headers || {}

  if (options.headers.Authorization == null &&
      options.basic_auth != null &&
      options.basic_auth.user != null &&
      options.basic_auth.pass != null)
  {
    var auth = options.basic_auth.user + ':' + options.basic_auth.pass
    options.headers['Authorization'] = 'Basic ' + new Buffer(auth).toString('base64')
  }

  for (var attribute in headers) {
    if (options.headers[attribute] === undefined) {
      options.headers[attribute] = headers[attribute]
    }
  }

  options.method = 'POST'
  this.options = options

  this.isSecure = isSecure
  this.headersProcessors = {
    processors: [],
    composeRequest: function(headers) {
      this.processors.forEach(function(p) {p.composeRequest(headers);})
    },
    parseResponse: function(headers) {
      this.processors.forEach(function(p) {p.parseResponse(headers);})
    }
  };
  if (options.cookies) {
    this.cookies = new Cookies();
    this.headersProcessors.processors.unshift(this.cookies);
  }
}
function Client ( options , isSecure ) { // Invokes with new if called without if ( false === ( this instanceof Client ) ) { return new Client ( options , isSecure ) } // If a string URI is passed in, converts to URI fields if ( typeof options === 'string' ) { options = url . parse ( options ) options . host = options . hostname options . path = options . pathname } if ( typeof options . url !== 'undefined' ) { var parsedUrl = url . parse ( options . url ) ; options . host = parsedUrl . hostname ; options . path = parsedUrl . pathname ; options . port = parsedUrl . port ; } // Set the HTTP request headers var headers = { 'User-Agent' : 'NodeJS XML-RPC Client' , 'Content-Type' : 'text/xml' , 'Accept' : 'text/xml' , 'Accept-Charset' : 'UTF8' , 'Connection' : 'Keep-Alive' } options . headers = options . headers || { } if ( options . headers . Authorization == null && options . basic_auth != null && options . basic_auth . user != null && options . basic_auth . pass != null ) { var auth = options . basic_auth . user + ':' + options . basic_auth . pass options . headers [ 'Authorization' ] = 'Basic ' + new Buffer ( auth ) . toString ( 'base64' ) } for ( var attribute in headers ) { if ( options . headers [ attribute ] === undefined ) { options . headers [ attribute ] = headers [ attribute ] } } options . method = 'POST' this . options = options this . isSecure = isSecure this . headersProcessors = { processors : [ ] , composeRequest : function ( headers ) { this . processors . forEach ( function ( p ) { p . composeRequest ( headers ) ; } ) } , parseResponse : function ( headers ) { this . processors . forEach ( function ( p ) { p . parseResponse ( headers ) ; } ) } } ; if ( options . cookies ) { this . cookies = new Cookies ( ) ; this . headersProcessors . processors . unshift ( this . cookies ) ; } }
Creates a Client object for making XML-RPC method calls.

@constructor
@param {Object|String} options - Server options to make the HTTP request to.
Either a URI string
(e.g. 'http://localhost:9090') or an object
with fields:
- {String} host              - (optional)
- {Number} port
- {String} url               - (optional) - may be used instead of host/port pair
- {Boolean} cookies          - (optional) - if true then cookies returned by server will be stored and sent back on the next calls.
Also it will be possible to access/manipulate cookies via #setCookie/#getCookie methods
@param {Boolean} isSecure      - True if using https for making calls,
otherwise false.
@return {Client}
Creates a Client object for making XML - RPC method calls .