xml - 内容类型 `application/xml` 在 Firefox 中显示扁平文本(失去 XML 结构)
问题描述
(基本上它与为什么 XML 文件没有在 Firefox 中正确呈现?相同的问题,但似乎没有答案适用于我)
我编写了一个发送 XML 输出(as application/xml
)的简单测试 HTTP 服务器。但是 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 会很好地显示它,甚至可以折叠它的一部分。
解决方案
这可能是一个扩展,显然有很多人这样做。这里还有一篇关于它的帖子。就我而言,它是“SwipeToNavigate”附加组件。
推荐阅读
- php - 从 WooCommerce 消息中删除链接
- reactjs - 在 React 中设置 Medium Feed
- javascript - html5隐藏所有div并在按钮单击时显示一个
- kubernetes - Kubernetes maxPods int32 还包括其默认的 pod
- macos - 使用 Open Firmware 设置硬件默认值
- java - 两个Fragment之间的接口通信
- nlp - 用于 CRF 分类器的 StanfordNLP 训练迭代
- r - 如何使用 quantmode 向多个烛台图表添加简单的移动平均线
- asp.net - Visual Studio 2017 不会编译我的 ASP.NET Web 项目,对肯定被引用的库说“无法加载文件或程序集”
- javascript - 空复选框上的 Javascript“空”验证消息