在iOS 11中将HTTP标头转换为小写 [英] http headers converted to lowercase in iOS 11

查看:78
本文介绍了在iOS 11中将HTTP标头转换为小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 11 Beta版上测试我的iPad应用程序时,我观察到一种独特的行为,即响应的HTTP标头会自动转换为小写字母.如何以编程方式更改此行为?由于标头名称已转换为小写字母,因此我们在实际的标头名称中签入了代码,这些代码不适用于iOS 11 beta.

While testing my iPad application on iOS 11 beta version, I observed a unique behaviour that HTTP headers coming in response are automatically converted to lowercase. How to change this behaviour programmatically? We have checks in code on the actual header name which aren't working with iOS 11 beta since header name is converted to lowercase.

推荐答案

回答此问题时,我假设您正在谈论的HTTP标头仅引用密钥,而不是标头的值.

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.

如果要与大写字符串进行比较,可以在标题上使用 NSString 实例方法 -uppercaseString .明智的做法是使代码不区分大小写,以防将来由于某种原因而编辑服务器以发送小写或大小写混合的标头.

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.

如果iOS将每个标头的值都转换为小写,那将是非常糟糕的.无论密钥或值框是否被修改,我都建议您向Apple提交错误报告.也许您可以使用Charles Web Proxy进行验证,以查看响应是否实际上已更改.

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.

祝你好运!

这篇关于在iOS 11中将HTTP标头转换为小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆