计算机网络,HTTP - 头部中带X前缀的头部字段
HTTP中,什么是"X-" Prefix header?
例如 github API 的response headers有很多X前缀的头部:
查一下MDN文档:
Custom proprietary headers have historically been used with an X- prefix, but this convention was deprecated in June 2012 because of the inconveniences it caused when nonstandard fields became standard in RFC 6648; others are listed in an IANA registry, whose original content was defined in RFC 4229. IANA also maintains a registry of proposed new HTTP headers.
原来是自定义头部。但是上面文档说,已经deprecated,过时了。
作用
和HTTP headers一样,都是提供额外的信息。
Their main purpose is for providing additional information
RFC表明X前缀的自定义头已经过时了,代替解决方案是什么?
根据keycdn,推荐继续保留:
Although the recommendation to use X- has been deprecated, it doesn’t mean that it is no longer supported. In fact, there are still many scenarios where X- continues to be used.
根据stackoverflow,推荐继续保留:
Just as there are many kids that will never end up as professional athletes, many custom headers will never end up as standards. I'm inclined to keep the "X-" on those
If you're using custom HTTP Headers (as a sometimes-appropriate alternative to cookies) within your app to pass data to/from your server, and these headers are, explicitly, NOT intended ever to be used outside the context of your application, name-spacing them with an "X-" or "X-FOO-" prefix is a reasonable, and common, convention.
总结
虽然RFC已经不推荐使用带X前缀的http 头部,但是不推荐不代表禁止。根据stackoverflow和google一些资料,推荐继续使用这样的自定义头部,有时候会提供极大的便利。经过本人观察,很多网站还在使用带X前缀的HTTP头部。
最新文章
- WPF模糊效果(BlurEffect)
- ButterKnife基本使用
- LeetCode() Largest Number
- 常用COBOL函数
- sql server 查询和Kill死锁进程
- 【转】Linux 文件夹文件创建与删除
- BI先特技软件 Analyzer安装时的部分问题
- nyist 47 过河问题
- Python内部类型
- python 二分法查找
- java_jdbc_batch处理_主键id获取
- JS的词法作用域
- 【三支火把】---队列和栈的C程序实现
- WWDC2014之iOS使用动态库
- gtk+blade+anjuta 的简单实例
- Cocos-2dx-Lua中使用Luaj的完整示例(转)
- 1.2为什么需要public static void main(String[] args)这个方法
- Dapper批量更新
- vue v-show绑定
- 如何用两块硬盘做磁盘阵列的教程Raid 1