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

fix: throw an error if the status code is a faulty one and stop the stream if a 204 is received #8

Closed
wants to merge 3 commits into from

Conversation

dunglas
Copy link

@dunglas dunglas commented Feb 10, 2022

Partial fix for #7.

A better fix would be to only allow 200, as stated by the spec, but this isn't possible without a BC break: it's not possible to create a new reqwest::Error for the other status codes.
We have a similar problem with the Content-Type: it must be set by the server to text/event-stream, and we should throw an error if it's not the case, but there is currently no corresponding reqwest::Error.

A better solution (at the cost of a BC break), is to introduce our custom error type (using thiserror or a similar crate). I suggest merging this patch as a quick fix for the current version, and to start working on a better implem in a new major version.

@jpopesculian
Copy link
Owner

Hi @dunglas! Thank you again for helping me bring things up to spec! I decided to go with latter approach you suggested with #9 which hopefully brings this a lot closer to what it should be. Take a look and let me know what you think!

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

Successfully merging this pull request may close these issues.

2 participants