首页 > 解决方案 > 使用 curl 保留 HTTP 标头的大小写

问题描述

我正在尝试使用 curl 发送带有自定义标头 ( curl http://example.com -H "Foo: bar") 的 HTTP 请求,我发现当标头到达时,它已被 curl 小写(上述标头Foo接收为foo: bar

如何在请求中保留标头的大小写?

标签: curlhttp-headers

解决方案


尝试强制 curl 使用 HTTP/1.1 - 它默认为 HTTP/2,该规范规定标头必须为小写。

curl http://example.com --http1.1 -H "Foo: bar"


推荐阅读