From a8a750ab05bdff73ba3af0b98f3f284ff8d1e743 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 27 Mar 2012 08:53:44 -0700 Subject: [PATCH] feat($http): make the transform defaults to an array $httpProvider.defaults.transformRequest and $httpProvider.defaults.transformResponse are now arrays containing single function. This makes it easy to add an extra transform fn. adding an extra fn before had to be done in this cluncky way: $httpProvider.defaults.transformResponse = [$httpProvider.defaults.transformResponse, myTransformFn]; after this change, it's simply: $httpProvider.defaults.transformResponse.push(myTransformFn); --- src/ng/http.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ng/http.js b/src/ng/http.js index 460618e31b08..9c4dafd4f0f5 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -90,7 +90,7 @@ function $HttpProvider() { var $config = this.defaults = { // transform incoming response data - transformResponse: function(data) { + transformResponse: [function(data) { if (isString(data)) { // strip json vulnerability protection prefix data = data.replace(PROTECTION_PREFIX, ''); @@ -98,12 +98,12 @@ function $HttpProvider() { data = fromJson(data, true); } return data; - }, + }], // transform outgoing request data - transformRequest: function(d) { + transformRequest: [function(d) { return isObject(d) && !isFile(d) ? toJson(d) : d; - }, + }], // default headers headers: {