http-types::Response::new might panic
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
Description
The current implementation of [http-types::Response::new](https://github.com/http-rs/http-types/blob/main/src/response.rs#L62) will panic on non-standard error codes such as the 52x ones returned by [Cloudflare](https://support.cloudflare.com/hc/en-us/articles/115003011431-Troubleshooting-Cloudflare-5XX-errors).
It looks like instead of returning an `Ok(Response::new(res.into()))`, the [send](https://github.com/http-rs/surf/blob/main/src/client.rs#L224) function should first test the `StatusCode` with `StatusCode::try_from::`.
I have also created an [issue](https://github.com/http-rs/http-types/issues/507) in http-types.
Contributor guide
Research direction
Start in src/client.rs at the send function around the Response::new call, then read http-types::Response::new in src/response.rs. Check how StatusCode::try_from handles non-standard codes such as Cloudflare's 52x responses. Done means these responses no longer cause a panic, with behavior consistent with the linked http-types issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100