简体   繁体   中英

Content-type `application/xml` is displaying flattened text (loosing XML structure) in Firefox

(Basically it is the same question as Why XML file is not rendered properly in Firefox? , but no answer seems to apply for me)

I wrote a simple test HTTP server that sends XML output (as application/xml ). However Firefox 78.13.0esr displays it as plain text, ie it leaves out all the element tags and spaces. Anyway when viewing the "page source" the XML is displayed correctly.

So I wonder whether it is a bug in Firefox, or whether my test server is doing something wrong (or I misunderstood something). The only extension being installed is the Adobe Acrobat PDF extension.

Here is the response header:

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

Here is the content:

<?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>

Finally this is what Firefox displays:

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

Note: If I send JSON as application/json , then Firefox displays it nicely, allowing to collapse parts of it even.

您可以尝试将内容类型更改为 text/xml,因为这在另一个页面上对我有用

It could be an extension and there are apparently a ton of them that do it. There's another post here all about it. In my case it is the "SwipeToNavigate" add-on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM