昨天我收到一封来自 GCP 的邮件,讲述了 Load Balancer 和大小写标题。消息的一部分是:
After September 30, HTTP(S) Load Balancers will convert HTTP/1.1 header names to lowercase in the request and response directions; header values will not be affected.
As header names are case-insensitive, this change will not affect clients and servers that follow the HTTP/1.1 specification (including all popular web browsers and open source servers). Similarly, as HTTP/2 and QUIC protocols already require lowercase header names, traffic arriving at load balancers over these protocols will not be affected. However, we recommend testing projects that use custom clients or servers prior to the rollout to ensure minimal impact.
Google 专门讨论了请求和响应 header 名称(不是值),但是,例如,Google Load Balancer 是否要求我将经典的 PHP 重定向 header “Location”替换为小写的“location”?
header("location: http://www.example.com/error/403");
当然,计划是按照标准说的去做,但在许多情况下,GCP 截止日期(2019 年 9 月 30 日)之前无法完成的工作。
按照标准,所有现代浏览器都准备好使用不区分大小写的 header 名称了吗? 我应该担心文件命名吗? ( Camel 箱) 如果是这样,Apache 中是否存在一些模块(例如)可以在我更改代码的同时使用?
最佳答案
HTTP/1.1 规范指定 HTTP header 不区分大小写。这仅适用于 header 名称(“content-type”)而不适用于 header 的值(“application/json”)。
如果这项新政策会给您带来问题,您可以联系 Google 支持并暂时选择退出。
对于正确编写并执行不区分大小写比较的代码,您不会有问题。在大多数情况下,您可以使用带有各种 HTTP header 的 curl
来测试您的后端代码。当然,完成代码走查是个好主意。
示例 curl 命令:
curl --http1.1 -H “x-goog-downcase-all-headers: test” http://example.com/
--http1.1 命令行选项的 Curl 文档: https://curl.haxx.se/docs/manpage.html
As is a standard, all modern browsers are prepared to use case insentive header names?
是的。长期以来,这一直是常态。
Should I be worry about files naming? (camelcases)
没有。新更改不会影响 HTTP header 的值,只会影响 header 名称。
If is the case, there exist some mod in Apache (for example) to use meanwhile I change my code?
没有,据我所知。
关于apache - GCP HTTP(S) 负载平衡器会将 HTTP/1.1 header 名称转换为小写,我的代码会受到影响吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56852315/