Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 7b3d8b6

Browse files
fix($http): propagate status -1 for aborted requests
Fixes #4491
1 parent addfc56 commit 7b3d8b6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/ng/http.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,8 +958,8 @@ function $HttpProvider() {
958958
* Resolves the raw $http promise.
959959
*/
960960
function resolvePromise(response, status, headers, statusText) {
961-
// normalize internal statuses to 0
962-
status = Math.max(status, 0);
961+
//status: HTTP response status code, 0, -1 (aborted by timeout / promise)
962+
status = status >= -1 ? status : 0;
963963

964964
(isSuccess(status) ? deferred.resolve : deferred.reject)({
965965
data: response,

test/ng/httpSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ describe('$http', function() {
13681368
$http({method: 'GET', url: '/some', timeout: canceler.promise}).error(
13691369
function(data, status, headers, config) {
13701370
expect(data).toBeUndefined();
1371-
expect(status).toBe(0);
1371+
expect(status).toBe(-1);
13721372
expect(headers()).toEqual({});
13731373
expect(config.url).toBe('/some');
13741374
callback();

0 commit comments

Comments
 (0)