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

fix($http): propagate status -1 for aborted requests #8756

Closed

Conversation

pkozlowski-opensource
Copy link
Member

Fixes #4491

@gabrielmaldi
Copy link
Contributor

Can I help with something to make this PR move forward?

@petebacondarwin
Copy link
Member

LGTM

@dizel3d
Copy link
Contributor

dizel3d commented Dec 22, 2015

Why this feature was introduced as patch for Angular 1.3.x? I think it is a breaking change and should be introduced in Angular 1.4.x. because many developers use 0 instead of -1. proof.

@petebacondarwin
Copy link
Member

@dizel3d - thanks for getting in touch. The status of an error was not defined as a public API in the Angular docs. The reason we used to (incorrectly) return 0 for all errors was that browsers were inconsistent in their error return values.
What we guarantee, which has not changed, is that successful requests would return a value between 200 and 299, inclusive.
To tell if a request errored, you should really be using an error handler via then(successFn, errorFn). What this added was a way of telling if the error was because of a timeout.
If you must use the status to check for an error, then perhaps you should test for <=0 rather than ==0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix($http) Indicate whether a request was aborted via status.
6 participants