Skip to content

Allow customizing header casing #670

Open
@svix-jplatte

Description

@svix-jplatte

Currently, the http crate contains a HeaderName type that is used in the implementation of HeaderMap as the key type. This HeaderName type stores all header names as lower case (for performance reasons), such that it is impossible¹ to (a) send headers with custom casing for the name and to (b) inspect the casing of headers for a request or response that was parsed into http::Request<_> / http::Response<_>.

In theory this shouldn't matter, because HTTP header names are specified to be case-insensitive. However in practice there are unfortunately many non-compliant implementations that don't work if you don't use the casing they expect.

Would you consider changes to the http crate that allow representing case-sensitive header names? I don't particularily care whether this would be done through some change to the HeaderName type, adding generics in some place, or even something entirely different, but I'd be happy to talk through different approaches if there is a general interest in solving this at the http crate level.

¹ without hacks such as abusing request / response extensions to store information about the casing, which hyper optionally supports on top of the http crate, c.f. hyperium/hyper#2695

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions