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

AjaxObservable: Redirections (including Not Modified) are wrapped in AjaxError. #3308

Closed
SleeplessByte opened this issue Feb 9, 2018 · 5 comments

Comments

@SleeplessByte
Copy link

SleeplessByte commented Feb 9, 2018

RxJS 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:
image

Additional information:

if (200 <= status && status < 300) {

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.

@claudiordgz
Copy link
Contributor

I'm grabbing this! ✋

@benlesh
Copy link
Member

benlesh commented Mar 15, 2018

@SleeplessByte thanks for reporting this. It looks like @claudiordgz would like to implement the fix.

@claudiordgz
Copy link
Contributor

Yes I would!

claudiordgz added a commit to claudiordgz/rxjs that referenced this issue Mar 16, 2018
w3 rfc2616 defines 4xx,5xx status codes as errors, but anything below is a valid response.
AjaxObservable errors when a request status returns 1xx and 3xx, passing only 2xx requests.

ReactiveX#3308
@claudiordgz
Copy link
Contributor

PR #3438 created, feedback super welcomed 🙏

benlesh pushed a commit that referenced this issue Mar 16, 2018
…xx (#3438)

w3 rfc2616 defines 4xx,5xx status codes as errors, but anything below is a valid response.
AjaxObservable errors when a request status returns 1xx and 3xx, passing only 2xx requests.

#3308
@SleeplessByte
Copy link
Author

This was merged (#3438) 2128932

@lock lock bot locked as resolved and limited conversation to collaborators Aug 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants