User Buffer for base64 encoding and remove withCredentials.
This commit is contained in:
@ -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",
|
||||
|
||||
12
src/lib/connectors/angular.js
vendored
12
src/lib/connectors/angular.js
vendored
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user