hyperium / http

Rust HTTP types
Apache License 2.0
1.12k stars 283 forks source link

Only lowercase HeaderNames allowed, but HTTP RFC states headers are case-insensitive #570

Closed Iso5786 closed 1 year ago

Iso5786 commented 1 year ago

Within https://github.com/hyperium/http/blob/master/src/header/name.rs#L1136 it states:

This function requires the static string to only contain lowercase characters, numerals and symbols, as per the HTTP/2.0 specification and header names internal representation within this library.

However, if I look into the HTTP 1.1 RFC 7230 section 3.2 (https://www.rfc-editor.org/rfc/rfc7230#section-3.2), it says there that:

Each header field consists of a case-insensitive field name followed by a colon (":"), optional leading whitespace, the field value, and optional trailing whitespace.

So I assume this is a bug, or do I overlook something here?

sfackler commented 1 year ago

The first quote talks about the HTTP/2.0 specification and the second quote is from the HTTP/1.1 specification.

Iso5786 commented 1 year ago

Indeed, I couldn't find it at first in the HTTP 2 spec so I assumed it's the same as in HTTP 1.1. However, https://blog.yaakov.online/http-2-header-casing/ explains it nicely. So this issue can be closed.