在iOS 11中,http标头转换为小写

时间:2017-07-14 08:08:10

标签: ios http-headers ios11

在iOS 11测试版上测试我的iPad应用程序时,我观察到一种独特的行为,即响应中的HTTP标头会自动转换为小写。如何以编程方式更改此行为?我们对实际标题名称的代码进行了检查,因为标题名称被转换为小写,所以它们不适用于iOS 11 beta。

2 个答案:

答案 0 :(得分:0)

When answering this I assume that the HTTP headers you are talking about are only referring to the key and not the value of the headers.

You could use the NSString instance method -uppercaseString on the headers in case you want to compare with uppercase strings. It is a smart move to make your code case insensitive in case the server for some reason is edited to send lowercase or mixed case headers in the future.

If iOS is making the value of each header lowercase then that is very bad. I would recommend you to submit a bug report to Apple no matter if the key or the value casing is modified. Maybe you can verify with Charles Web Proxy to see that the response are actually changed.

Good luck!

答案 1 :(得分:0)

注意 - 标题转换为小写的做法符合HTTP 2.0规范的准备。对于HTTP 1.0,标题应该是不区分大小写的僵尸程序,并不总是遵循。 见https://evertpot.com/http-2-finalized/

Chrome更新60已经更改,因此响应标题现在是小写的(这会导致我们出现一些问题!)

预计所有浏览器都将跟随即将推出的更新,因此您需要处理这些问题