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

Cloudfare status codes #507

Open
mihai-dinculescu opened this issue Aug 1, 2022 · 2 comments
Open

Cloudfare status codes #507

mihai-dinculescu opened this issue Aug 1, 2022 · 2 comments

Comments

@mihai-dinculescu
Copy link

Cloudflare seems to be defining a few custom error codes in the 5xx area. Not cool, I know.
https://support.cloudflare.com/hc/en-us/articles/115003011431-Troubleshooting-Cloudflare-5XX-errors

The StatusCode enum doesn't contain them, and this causes a panic in the Response constructor. https://github.com/http-rs/http-types/blob/main/src/status_code.rs

Is there a plan to add these error codes to the enum or to rework it in such a way that the Response constructor doesn't panic?

@jbr
Copy link
Member

jbr commented Aug 1, 2022

Are these Responses being constructed with a proxy? Can the proxy call StatusCode::try_from::<u16> on the original status before constructing a response from it and replace the status with a standard one? This isn't mutually exclusive with one of the other fixes you suggest but would certainly be faster than a breaking change to http-types

@mihai-dinculescu
Copy link
Author

I've experienced a panic from surf. I will raise a ticket in their repo as well.

However, wouldn't the Response implementation be a lot more user-friendly (yes, I'm avoiding the idiomatic word here) if it would return an Err(NonStandardErrorCode) instead of panicking and forcing all upstream callers to make sure that only valid status codes are passed?

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

No branches or pull requests

2 participants