Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http always return status 200 #2841

Closed
Delagen opened this issue Jul 2, 2015 · 9 comments
Closed

Http always return status 200 #2841

Delagen opened this issue Jul 2, 2015 · 9 comments

Comments

@Delagen
Copy link
Contributor

Delagen commented Jul 2, 2015

http
            .post("/api/cap/user/ping2")
            .toRx()
            //.map((response:Response) => response.json())
            .subscribe(
            (data:Object) => console.log(data),
            (data:Object) => console.error(data),
            (data:Object) => console.debug(data)
        );

In network tab on developer tools in browser status 404.
But in console always object with status 200.

@vicb
Copy link
Contributor

vicb commented Jul 2, 2015

release / SHA1 please ?

@Delagen
Copy link
Contributor Author

Delagen commented Jul 2, 2015

latest alpha 29 npm release

@timjacobi
Copy link

https://github.com/angular/angular/blob/master/modules/angular2/src/http/backends/xhr_backend.ts#L40
Looks like the actual status code, among other properties, is not returned. Happy to provide a fix. Could anyone point out which properties are expected to be returned please?

@caitp
Copy link
Contributor

caitp commented Jul 3, 2015

@timjacobi you can get the status code from this._xhr.status --- this can do weird things sometimes though, like incorrectly reporting a network error status for file:/// requests (IIRC). There is code in 1.x $http working around that.

@timjacobi
Copy link

Thanks for info. Plan of action then? I have some time this weekend :)

@caitp
Copy link
Contributor

caitp commented Jul 3, 2015

well OTOH, an MVP fix would just pass this._xhr.status into the Response constructor (by adding another property status to the object) --- that may be enough to do it. We could worry about translating the network error status on mobile later. Feel free to send a PR

PatrickJS added a commit to PatrickJS/angular that referenced this issue Jul 5, 2015
PatrickJS added a commit to PatrickJS/angular that referenced this issue Jul 10, 2015
PatrickJS added a commit to PatrickJS/angular that referenced this issue Jul 27, 2015
@PatrickJS
Copy link
Member

I have a PR open with the fix #2882

@aboeglin
Copy link

aboeglin commented Aug 7, 2015

The bug concerning the status seems to be fixed on my tests, but the statusText still defaults to Ok. Maybe we could have a test on the status code and use the generic http error ( Internal Server Error and so on ). Also, it seems that the EventEmitter returned by Http.request() is calling Observer.next() even when status reports an error. In case of a 4xx or 5xx it should rather pass it to Observer.throw().

edit : actually I found it, there's already an issue for it : #2800

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants