fix($http): anonnymous response interceptors should be treated as factories

This commit is contained in:
Igor Minar 2012-01-12 16:50:31 -08:00
parent 939c8e8fac
commit b7f4d8c3c3
2 changed files with 12 additions and 6 deletions

View file

@ -125,7 +125,11 @@ function $HttpProvider() {
responseInterceptors = [];
forEach(providerResponseInterceptors, function(interceptor) {
responseInterceptors.push(isString(interceptor) ? $injector.get(interceptor) : interceptor);
responseInterceptors.push(
isString(interceptor)
? $injector.get(interceptor)
: $injector.invoke(interceptor)
);
});

View file

@ -51,11 +51,13 @@ describe('$http', function() {
};
});
// just change the response data and pass the response object along
$httpProvider.responseInterceptors.push(function(httpPromise) {
return httpPromise.then(function(response) {
response.data += '!';
return response;
});
$httpProvider.responseInterceptors.push(function() {
return function(httpPromise) {
return httpPromise.then(function(response) {
response.data += '!';
return response;
});
}
});
// return a new resolved promise representing modified response object