sjehuda / Newspaper

First check HEADER, then GET content @7nik.

Call twice to XMLHTTPRequest.

Once with HEAD and XMLHttpRequest.readyState === 2 (HEADERS_RECEIVED) and if page is a Feed; then

Once again with GET and XMLHttpRequest.readyState === 3 (LOADING) or 4 (DONE) when MIME-Type doesn't say ATOM or RSS but we find out that it is.

Code; courtesy of 7nik

Just use fetch, it is more simple. This should work:

async function httpGetAsync(uri, callback) {
  let resp = await fetch(uri, { method: "HEAD" });
  if (!resp.ok) resp = await fetch(uri);
  const mimeType = resp.headers.get("Content-Type");

Plan cancelled.

Thos program, now, takes the content, regardless of content-type header, and determines whether data is feed or is not.