2

I've created a custom MIME type called application/x-mytype with extension .mytype following this link. Then, I created a file in my server named test.mytype and I'm trying to get it's Content-Type via XMLHttpRequest but it looks like the browser cannot detect it.

var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
} else {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.open("GET", "https://{myserver}/test.mytype", true);
xmlhttp.send(null);

xmlhttp.onreadystatechange = function (oEvent) {
    if(xmlhttp.readyState==4) {
        var contentType = xmlhttp.getResponseHeader('content-type');
        console.log(contentType); // prints null

        if(contentType === 'application/x-mytype') {
            // never arrives here
        } 
    } 
}; 

If I look at my "file type" via Windows Explorer, I can see my custom type, so it is looking at Windows registries. Do I have to set anything else or browsers aren't supposed to identify my custom MIME type?

Community
  • 1
  • 1
lucasdc
  • 1,032
  • 2
  • 20
  • 42

0 Answers0