http-rs / http-rs/http-types

Consider more rigorous handling of http::StatusCode conversion to StatusCode

Open
#183 12 comments 0 reactions 0 assignees View on GitHub
bug semver-major
Dominant language
Rust
Stars
209
Forks
91
PR merge metrics
No merged PRs in 30d

Description

Right now conversion from `http::StatusCode` (which is just an `u16` in `100..=600` range) to `StatusCode` just expect()s the result for example here:
https://github.com/http-rs/http-types/blob/539638273de768a24354b65999ad9317b6659204/src/response.rs#L101-L103

this could cause a crash in response conversion for example here:
https://github.com/http-rs/http-types/blob/539638273de768a24354b65999ad9317b6659204/src/hyperium_http.rs#L123

if some server responds erroneously with some status that belongs to 100..=600 range but is not implemented in `StatusCode` enum (for example 229), the conversion `From> for Response` will panic despite it being `From` and not `TryFrom`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.