From 90559ead064845e295496c357ccaa20dd650256d Mon Sep 17 00:00:00 2001 From: Jeff French Date: Thu, 13 Feb 2014 20:02:40 -0600 Subject: [PATCH] User Buffer for base64 encoding and remove withCredentials. --- package.json | 3 +-- src/lib/connectors/angular.js | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 63bea2c8c..b9676fbb9 100644 --- a/package.json +++ b/package.json @@ -69,8 +69,7 @@ "chalk": "~0.3.0", "forever-agent": "~0.5.2", "lodash-node": "~2.3.0", - "when": "~2.6.0", - "js-base64": "~2.1.2" + "when": "~2.6.0" }, "repository": { "type": "git", diff --git a/src/lib/connectors/angular.js b/src/lib/connectors/angular.js index 52f051e36..a2bde6711 100644 --- a/src/lib/connectors/angular.js +++ b/src/lib/connectors/angular.js @@ -9,30 +9,26 @@ module.exports = AngularConnector; var _ = require('../utils'); var ConnectionAbstract = require('../connection'); var ConnectionFault = require('../errors').ConnectionFault; -var base64 = require('js-base64').Base64; function AngularConnector(host, config) { ConnectionAbstract.call(this, host, config); this.defer = config.defer; this.$http = config.$http; + if(this.host.auth) { + this.$http.defaults.headers.common.Authorization = 'Basic ' + Buffer(this.host.auth, 'utf8').toString('base64'); + } } _.inherits(AngularConnector, ConnectionAbstract); AngularConnector.prototype.request = function (params, cb) { var abort = this.defer(); - var headers = {}; - if(this.host.auth) { - headers['Authorization'] = 'Basic ' + base64.encode(this.host.auth); - } this.$http({ method: params.method, url: this.host.makeUrl(params), data: params.body, cache: false, transformRequest: [], - transformResponse: [], - headers: headers, - withCredentials: !!this.host.auth + transformResponse: [] }).then(function (response) { cb(null, response.data, response.status, response.headers()); }, function (err) {