Http: a bodyless GET is sent with Content-Type: text/plain, and with no User-Agent (GitHub's API answers 403)
维护者通常 1 天内回复
已经有一个关联 PR 被合并了。
- #534 来自 @lukewilliamboswell —— 已合并
评估
调研方向
Start by locating Http.send! and send_streaming!, then trace how they add default headers when building a request. Check the HTTP tests for bodyless GET requests and requests with a caller supplied User-Agent. Done means the defaults match the intended behavior for both cases, with tests covering each.
由索引模型根据 Issue 内容生成。
描述
Two default headers surprised me while porting a tool to 0.26.0-rc3:
1. A bodyless GET is sent with Content-Type: text/plain. send_streaming! adds Content-Type: text/plain to any request that does not set one, even when there is no body. What Http.send! sends for Request.from_method(GET).with_uri("http://127.0.0.1:18099/x"), captured with nc -l -p 18099:
GET /x HTTP/1.1
content-type: text/plain
host: 127.0.0.1:18099
A Content-Type describes content, and this request has none. Servers mostly ignore it, but a strict one can refuse it, and it is a header the caller never asked for. Suggestion: add the default only when the body is not empty, or not at all.
2. No User-Agent. GitHub's REST API refuses requests without one:
api = Http.send!(Request.from_method(GET).with_uri("https://api.github.com/repos/roc-lang/basic-cli/branches/main"), {})?
# Response.status(api) == 403
With .add_header("User-Agent", "something") it answers 200. curl, Go's net/http and Python's urllib each send one by default. GitHub is probably the most common API a CLI script talks to, and a 403 with a body about a missing User-Agent is easy to miss. Suggestion: a default such as roc-basic-cli/0.26, replaced by any User-Agent the request sets. Or a line in Http's docs, if a default is not wanted.
Seen on 0.26.0-rc3, Roc nightly-2026-10-17-5f126ac and -10-19, Linux x86_64. Thank you for rc3: details on how it went for us are in #529.
- 主要语言
- Rust
- 星标
- 122
- 派生
- 47
- 平均合并
- 11 小时 6 分钟
- 30 天内合并 PR
- 21
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
roc-lang/basic-cli 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 45/100
roc-lang/basic-cli#500 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
roc-lang/basic-cli#482 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 45/100
roc-lang/basic-cli#455 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 32/100
维护者通常 1 天内回复
查看 roc-lang/basic-cli 的全部 Issue
相似的 Issue
-
bug cli p3
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Telegram and Twitch adapters panic when splitting long messages with multibyte characters可能已有人在做 @RaphaelFakhri 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
spacedriveapp/spacebot#661 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
project-robius/robrix#1177 ·
维护者通常 1 天内回复