Skip to content

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

Open
@khodzha

Description

@khodzha

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:

http-types/src/response.rs

Lines 101 to 103 in 5396382

let status = status
.try_into()
.expect("Could not convert into a valid `StatusCode`");

this could cause a crash in response conversion for example here:

let mut res = Response::new(parts.status);

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<http::Response<Body>> for Response will panic despite it being From and not TryFrom

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsemver-majorThis change requires a semver major change

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions