zoukankan      html  css  js  c++  java
  • 计算机网络,HTTP

    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头部。

  • 相关阅读:
    swiper-wrapper轮滑组件(多组轮滑界面)间隔无效问题
    jquery .play()报错is not a function
    html 表单input disabled属性提交后台无法获得数据
    git报错:Auto Merge Failed; Fix Conflicts and Then Commit
    js 获取转换网址中文参数
    day36 作业
    day38 并发编程(理论)
    day35 作业
    day36 解决粘包问题
    day35 socket套接字介绍
  • 原文地址:https://www.cnblogs.com/allen2333/p/12069791.html
Copyright © 2011-2022 走看看