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

Commit 38520a1

Browse files
fix($http): propagate status -1 for timed out requests
Fixes #4491 Closes #8756
1 parent 470eb37 commit 38520a1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/ng/http.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1289,8 +1289,8 @@ function $HttpProvider() {
12891289
* Resolves the raw $http promise.
12901290
*/
12911291
function resolvePromise(response, status, headers, statusText) {
1292-
// normalize internal statuses to 0
1293-
status = Math.max(status, 0);
1292+
//status: HTTP response status code, 0, -1 (aborted by timeout / promise)
1293+
status = status >= -1 ? status : 0;
12941294

12951295
(isSuccess(status) ? deferred.resolve : deferred.reject)({
12961296
data: response,

test/ng/httpSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,7 @@ describe('$http', function() {
17341734
$http({method: 'GET', url: '/some', timeout: canceler.promise}).error(
17351735
function(data, status, headers, config) {
17361736
expect(data).toBeUndefined();
1737-
expect(status).toBe(0);
1737+
expect(status).toBe(-1);
17381738
expect(headers()).toEqual({});
17391739
expect(config.url).toBe('/some');
17401740
callback();

0 commit comments

Comments
 (0)