Skip to content

A type to represent a valid HeaderValue and String #257

Open
@seanmonstar

Description

@seanmonstar

A HeaderValue may not always be a valid UTF-8 String, and so there is a to_str(&self) -> Result<&str, ToStrError> method that validates the bytes first. To create a String, one could instead do String::from_utf8(value.as_bytes()), but once you have that String, you'll need to re-validate it to turn it back into a HeaderValue.

It would be useful to have a type that represents being both a valid HeaderValue and a valid String at the same time. This type would have a free as_str() method, since it's already been validated, and conversely a free into_value() method (again, because it's already validated).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-headersArea: HTTP headersB-rfcBlocked: request for comments. More discussion would help move this along.S-featureSeverity: feature. This adds something new.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions