使用“X-...”是安全的HTTP 响应中的标头?
我必须在 HTTP 响应中传递元信息,因此我发现可以使用响应标头,例如“X-MyData: 123456”。这样安全吗?我的意思是,客户端代理有可能删除此标头吗?
谢谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我必须在 HTTP 响应中传递元信息,因此我发现可以使用响应标头,例如“X-MyData: 123456”。这样安全吗?我的意思是,客户端代理有可能删除此标头吗?
谢谢!
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
作为参考,X- 标头在 RFC 2045,作为 RFC 2047 以及 新闻文章格式草稿。
反对在应用程序协议中使用“X-”前缀(BCP,2012 年 6 月):
For reference, X- headers are also referred to as
x-token
in the BNF of RFC 2045, asuser-defined ("X-")
in section 5 of RFC 2047 and as Experimental headers in section 4.2.2.1 of the News Article Format draft.Deprecating Use of the "X-" Prefix in Application Protocols (BCP, June 2012):
客户端代理可以做任何它想做的事情,但通常不会剥离任何标头。
以 X- 开头的标头通常保留用于非标准用途(即,未来的标准不会引入以 X- 开头的标头),但代理可以理解它们并选择根据需要修改它们。
A client proxy could do anything it wanted, but in general would not strip any headers.
Headers starting with an X- are typically reserved for nonstandard usage (i.e. no future standard will introduce a header starting X-) but a proxy may understand them and choose to modify them as it wants.
代理服务器或链中的任何中间链接可能修改您的标头,但这通常不是问题。
通常,指定自定义标头就可以,只要它们足够独特,不会与其他人的标头发生冲突,并且您不希望其他人使用您的标头。
It is possible for proxy servers or any intermediate links in the chain to modify your headers, but this usually isn't a problem.
More often than not, specifying custom headers is fine as long as they're unique enough not to conflict with other people's headers and you don't expect anyone else to use yours.