* Callback registered to $httpBackend(): * - caches the response if desired * - resolves the raw $http promise * - calls $apply
(status, response, headersString, statusText, xhrStatus)
| 12757 | * - calls $apply |
| 12758 | */ |
| 12759 | function done(status, response, headersString, statusText, xhrStatus) { |
| 12760 | if (cache) { |
| 12761 | if (isSuccess(status)) { |
| 12762 | cache.put(url, [status, response, parseHeaders(headersString), statusText, xhrStatus]); |
| 12763 | } else { |
| 12764 | // remove promise from the cache |
| 12765 | cache.remove(url); |
| 12766 | } |
| 12767 | } |
| 12768 | |
| 12769 | function resolveHttpPromise() { |
| 12770 | resolvePromise(response, status, headersString, statusText, xhrStatus); |
| 12771 | } |
| 12772 | |
| 12773 | if (useApplyAsync) { |
| 12774 | $rootScope.$applyAsync(resolveHttpPromise); |
| 12775 | } else { |
| 12776 | resolveHttpPromise(); |
| 12777 | if (!$rootScope.$$phase) $rootScope.$apply(); |
| 12778 | } |
| 12779 | } |
| 12780 | |
| 12781 | |
| 12782 | /** |
no test coverage detected