XML Parsing Error: no root element found
Categories
(Core :: DOM: Networking, defect)
Tracking
()
People
(Reporter: nathan.gerhart, Unassigned)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:66.0) Gecko/20100101 Firefox/66.0
Steps to reproduce:
When making an ajax request, I receive an unexpected console error when the response is a 404 with an empty body and no content-type
header.
As a minimal and reproducible example, I set up this Glitch project to return a response that triggers the behavior.
Run the following from the browser console on an empty about:blank window:
xhr = new XMLHttpRequest()
xhr.open('get','https://aquamarine-editorial.glitch.me',true)
xhr.send(null)
Actual results:
The network tab shows a 404 response with the following headers:
HTTP/2.0 404 Not Found
date: Thu, 09 May 2019 03:04:59 GMT
content-length: 0
x-powered-by: Express
access-control-allow-origin: *
etag: W/"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"
X-Firefox-Spdy: h2
A noisy console error message is shown, which says
XML Parsing Error: no root element found
Location: https://aquamarine-editorial.glitch.me/
Line Number 1, Column 1:
Expected results:
I expect the content-length
of 0 to prevent attempted/failed parsing of the body, which is the behavior in Chrome 74.
It does not appear that response bodies are required on 404. https://tools.ietf.org/html/rfc7231#section-6.5 says:
Except when responding to a HEAD request, the
server SHOULD send a representation containing an explanation of the
error situation, and whether it is a temporary or permanent
condition.
I can work around this issue by returning either a body or include the header content-type: text/html
Comment 1•5 years ago
|
||
For future reference, you can avoid reporting fixed bugs by testing the latest Nightly in a brand new profile.
Description
•