【发布时间】:2021-09-03 06:26:06
【问题描述】:
(基本上和Why XML file is not rendered properly in Firefox?是同一个问题,但似乎没有适合我的答案)
我编写了一个发送 XML 输出的简单测试 HTTP 服务器(如application/xml)。
然而 Firefox 78.13.0esr 将其显示为纯文本,即它忽略了所有元素标签和空格。
无论如何,在查看“页面源”时,XML 会正确显示。
所以我想知道这是否是 Firefox 中的错误,或者我的测试服务器是否做错了什么(或者我误解了什么)。 唯一安装的扩展是 Adobe Acrobat PDF 扩展。
这是响应头:
HTTP/1.1 200 All bits are up
Date: Fri, 03 Sep 2021 06:02:29 GMT
Server: libwww-perl-daemon/6.01
Content-Length: 604
Content-Type: application/xml
Charset: utf-8
这是内容:
<?xml version="1.0" encoding="utf-8"?>
<MonitoringOutput id="foo-test" version="0.1">
<description>a simple test only</description>
<exit_code>0</exit_code>
<status_string>OK</status_string>
<info_string>response_time(passwd:nagios) is 0.006 (0)</info_string>
<perf_string> passwd_nagios=0.006;0;0;0</perf_string>
<perf_data count="1">
<sample label="passwd_nagios">
<label>passwd_nagios</label>
<value>0.006</value>
<thresholds>
<warn end="0"/>
<crit end="0"/>
</thresholds>
<range min="0"/>
</sample>
</perf_data>
</MonitoringOutput>
这就是 Firefox 显示的内容:
a simple test only 0 OK response_time(passwd:nagios) is 0.006 (0) passwd_nagios=0.006;0;0;0 passwd_nagios 0.006
注意:如果我将 JSON 发送为 application/json,那么 Firefox 会很好地显示它,甚至可以折叠部分内容。
【问题讨论】: