* Callback registered to $httpBackend(): * - caches the response if desired * - resolves the raw $http promise * - calls $apply
(status, response, headersString, statusText)
| 10344 | * - calls $apply |
| 10345 | */ |
| 10346 | function done(status, response, headersString, statusText) { |
| 10347 | if (cache) { |
| 10348 | if (isSuccess(status)) { |
| 10349 | cache.put(url, [status, response, parseHeaders(headersString), statusText]); |
| 10350 | } else { |
| 10351 | // remove promise from the cache |
| 10352 | cache.remove(url); |
| 10353 | } |
| 10354 | } |
| 10355 | |
| 10356 | function resolveHttpPromise() { |
| 10357 | resolvePromise(response, status, headersString, statusText); |
| 10358 | } |
| 10359 | |
| 10360 | if (useApplyAsync) { |
| 10361 | $rootScope.$applyAsync(resolveHttpPromise); |
| 10362 | } else { |
| 10363 | resolveHttpPromise(); |
| 10364 | if (!$rootScope.$$phase) $rootScope.$apply(); |
| 10365 | } |
| 10366 | } |
| 10367 | |
| 10368 | |
| 10369 | /** |