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

Commit f13055a

Browse files
fix($http): propagate status -1 for timed out requests
Fixes #4491 Closes #8756
1 parent 623ce1a commit f13055a

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
@@ -1110,8 +1110,8 @@ function $HttpProvider() {
11101110
* Resolves the raw $http promise.
11111111
*/
11121112
function resolvePromise(response, status, headers, statusText) {
1113-
// normalize internal statuses to 0
1114-
status = Math.max(status, 0);
1113+
//status: HTTP response status code, 0, -1 (aborted by timeout / promise)
1114+
status = status >= -1 ? status : 0;
11151115

11161116
(isSuccess(status) ? deferred.resolve : deferred.reject)({
11171117
data: response,

test/ng/httpSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,7 @@ describe('$http', function() {
16571657
$http({method: 'GET', url: '/some', timeout: canceler.promise}).error(
16581658
function(data, status, headers, config) {
16591659
expect(data).toBeUndefined();
1660-
expect(status).toBe(0);
1660+
expect(status).toBe(-1);
16611661
expect(headers()).toEqual({});
16621662
expect(config.url).toBe('/some');
16631663
callback();

0 commit comments

Comments
 (0)