Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Header fields should be case insensitive (RFC 7230 §3.2, RFC 9110 §5.1)

未关闭
#735 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
rust
领域
api, networking

调研方向

首先检查 HeaderMap::get 和 HeaderMap::insert 与 HeaderName::from_static 一起使用时的行为,并使用 issue 中区分大小写的示例作为复现用例。完成的标准是:获取 header 名称时接受不同的大小写,from_static 对有效字段名不再 panic,并且保留原始大小写。

由索引模型根据 Issue 内容生成。

描述

I'm working with http::HeaderMap and noticed that HeaderMap::get, HeaderMap::insert, and HeaderName::from_static all seem to be case sensitive (in fact, the latter panics:

HeaderName::from_static("Content-Type")

panics with:

index out of bounds: the len is 0 but the index is 0

while:

HeaderName::from_static("content-type")

does not.

This goes against the HTTP spec requiring case-insensitive handling of header values:

  • RFC 7230 §3.2

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

  • RFC 9110 §5.1

    Field names are case-insensitive...

IMO, this is distinct from #670, and in fact case-insensitive keys should solve that issue as well, while not requiring the original cases to be changed.

It looks like crates like case_insensitive_hashmap and unicase are examples of case-insensitive String handling.

Is there any way to just make the HeaderMap case-insensitive for retrieval? That would preserve original case as well as allow any case for HeaderMap::get to meet the spec and prevent errors.

主要语言
Rust
星标
1.4k
派生
378
平均合并
1 天 21 小时
30 天内合并 PR
5

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

hyperium/http 的其他 Issue

查看 hyperium/http 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。