AjaxObservable: Redirections (including Not Modified) are wrapped in AjaxError.
See original GitHub issueRxJS version: 5.5.6 / stable
Code to reproduce:
const request: AjaxRequest = {
...requestThatWillReturnAStatusCodeAbove299Below400
}
Observable
.ajax(request)
.subscribe(console.log, console.error)
Expected behavior:
I get the AjaxResponse
in the console.log, just like any 2XX response.
Actual behavior:
Additional information: https://github.com/ReactiveX/rxjs/blob/94156a214f905555b6e57bc3f7cf965629028406/src/internal/observable/dom/AjaxObservable.ts#L368
Over here for some reason it defines only status between 200 and 300 (Exclusive) to be “next” worthy. The rest is all piped to an AjaxError. Status codes starting at 400 should error, but the (1XX,) 2XX and 3XX should all be valid responses.
Redirects are (rightly so) not handled, but it should not be an error. Since you get the raw AjaxResponse
anyway, you’ll need handling regardless; but why make a “regular case” (think 304 Not Modified, or a 302 Found) a wrapped result into AjaxError
.
https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 4XX
and 5XX
are errors.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:5 (4 by maintainers)
I’m grabbing this! ✋
This was merged (#3438) https://github.com/ReactiveX/rxjs/commit/2128932ab219cdba0f18b512e552500e7fab4029