加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

我应该为XML网站地图发送什么Content-Type值?

发布时间:2020-12-16 08:16:55 所属栏目:百科 来源:网络整理
导读:我想我应该发送“text / xml”,但后来我读到,我应该发送“application / xml”。有关系吗?有人可以解释差别吗? 如果charset参数为ommitted,则 difference between text/xml and application/xml 是缺省字符编码: Text/xml and application/xml behave
我想我应该发送“text / xml”,但后来我读到,我应该发送“application / xml”。有关系吗?有人可以解释差别吗?
如果charset参数为ommitted,则 difference between text/xml and application/xml是缺省字符编码:

Text/xml and application/xml behave differently when the charset
parameter is not explicitly specified. If the default charset (i.e.,
US-ASCII) for text/xml is inconvenient for some reason (e.g.,bad web
servers),application/xml provides an alternative (see “Optional
parameters” of application/xml registration in Section 3.2).

对于text/xml

Conformant with [RFC2046],if a text/xml entity is received with
the charset parameter omitted,MIME processors and XML processors
MUST use the default charset value of “us-ascii”[ASCII]. In cases
where the XML MIME entity is transmitted via HTTP,the default
charset value is still “us-ascii”.

对于application/xml

If an application/xml entity is received where the charset
parameter is omitted,no information is being provided about the
charset by the MIME Content-Type header. Conforming XML
processors MUST follow the requirements in section 4.3.3 of [XML]
that directly address this contingency. However,MIME processors
that are not XML processors SHOULD NOT assume a default charset if
the charset parameter is omitted from an application/xml entity.

因此,如果省略charset参数,则text / xml的字符编码为US-ASCII,而使用application / xml,可以在文档本身中指定字符编码。

现在在互联网上的一个经验法则是:“严格输出,但容忍输入。”这意味着确保在通过互联网传递数据时尽可能地满足标准。但是建立一些机制来忽略错误或在通过互联网接收和解释数据时猜测。

所以在你的情况下,只是选择两种类型之一(我推荐application / xml),并确保正确指定使用的字符编码(我建议使用相应的默认字符编码,以安全,所以在application / xml使用情况下UTF-8或UTF-16)。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读