* Callback registered to $httpBackend(): * - caches the response if desired * - resolves the raw $http promise * - calls $apply
(status, response, headersString, statusText, xhrStatus)
| 13391 | * - calls $apply |
| 13392 | */ |
| 13393 | function done(status, response, headersString, statusText, xhrStatus) { |
| 13394 | if (cache) { |
| 13395 | if (isSuccess(status)) { |
| 13396 | cache.put(url, [status, response, parseHeaders(headersString), statusText, xhrStatus]); |
| 13397 | } else { |
| 13398 | // remove promise from the cache |
| 13399 | cache.remove(url); |
| 13400 | } |
| 13401 | } |
| 13402 | |
| 13403 | function resolveHttpPromise() { |
| 13404 | resolvePromise(response, status, headersString, statusText, xhrStatus); |
| 13405 | } |
| 13406 | |
| 13407 | if (useApplyAsync) { |
| 13408 | $rootScope.$applyAsync(resolveHttpPromise); |
| 13409 | } else { |
| 13410 | resolveHttpPromise(); |
| 13411 | if (!$rootScope.$$phase) $rootScope.$apply(); |
| 13412 | } |
| 13413 | } |
| 13414 | |
| 13415 | |
| 13416 | /** |
no test coverage detected