diff --git a/src/ng/http.js b/src/ng/http.js index 9017fe85292d..757620c95319 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -958,8 +958,8 @@ function $HttpProvider() { * Resolves the raw $http promise. */ function resolvePromise(response, status, headers, statusText) { - // normalize internal statuses to 0 - status = Math.max(status, 0); + //status: HTTP response status code, 0, -1 (aborted by timeout / promise) + status = status >= -1 ? status : 0; (isSuccess(status) ? deferred.resolve : deferred.reject)({ data: response, diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index c1c33ffb8788..cf76b5d8b3c6 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -1368,7 +1368,7 @@ describe('$http', function() { $http({method: 'GET', url: '/some', timeout: canceler.promise}).error( function(data, status, headers, config) { expect(data).toBeUndefined(); - expect(status).toBe(0); + expect(status).toBe(-1); expect(headers()).toEqual({}); expect(config.url).toBe('/some'); callback();