为什么 'x-www-form-urlencoded' 以 'x-www' 开头,而其他标准内容类型却没有?

Why does 'x-www-form-urlencoded' begin with 'x-www', when other standard content types do not?

我知道在过去,自定义 headers 名称使用前缀 "X-" 是标准做法(我知道这样做不再被认为是标准做法),但我一直找不到这个命名约定和值("application/x-www-form-urlencoded")之间是否有任何关系。它最初是作为后来采用的自定义 content-type 值还是什么?

我在这里找到了 this link,这当然很有趣,但一直无法找到我问题的答案。

有人知道选择这个前缀的原因及其含义吗?

it was standard for custom headers names to use the prefix "X-"

实际上……不,一点也不。准确地说:它从来都不是一个标准,只是一个最佳实践。它允许实施者引入新的内容类型和编码,而无需为其编写完整的 RFC。如今 IANA Media Type Registry is good for that. RFC 6648 结束了这种做法。

application/x-www-form-urlencoded 以这种方式作为前缀的原因(它在上述注册表中被列为正确的 MIME 类型,顺便说一句))源于这样一个事实,即它是一种构造查询字符串的“自定义”方法在URL。那部分有。 HTML后面的人就这么去做了,充分证明了前缀。

就历史而言:它有 x- 前缀,因为它起源于 a proposal from Mosaic——因为它只是一个提案,他们最初使用 x- 扩展前缀定义它。但是后来其他浏览器也以这种方式实现了它,而且没有人抽出时间来适当地标准化一个没有前缀的替代方案,所以它就这样停滞不前,现在就是这样。

它可以追溯到 1993 年 www-talk 邮件列表上标题为“向服务器提交 input-form 数据”的帖子,在该帖子中,a September 1993 message from Marc Andreessen:

This is what we're doing in Mosaic 2.0… See

http://www.ncsa.uiuc.edu/SDG/Software/Mosaic/Docs/fill-out-forms/overview.html

...for details on what we're up to

link 现在已损坏,但标题为“Mosaic for X version 2.0 Fill-Out Form Support”的文档是 archived at archive.org。以下是相关摘录:

ENCTYPE specifies the encoding for the fill-out form contents. This attribute only applies if METHOD is set to POST -- and even then, there is only one possible value (the default, application/x-www-form-urlencoded) so far.

无论如何,application/x-www-form-urlencoded is now formally defined in the URL spec,使用解析和序列化它的算法——尽管它全部定义的部分有这样的注释:

The application/x-www-form-urlencoded format is in many ways an aberrant monstrosity, the result of many years of implementation accidents and compromises leading to a set of requirements necessary for interoperability, but in no way representing good design practices. In particular, readers are cautioned to pay close attention to the twisted details involving repeated (and in some cases nested) conversions between character encodings and byte sequences. Unfortunately the format is in widespread use due to the prevalence of HTML forms.