Q:

HTTP Content Type in Header

I have old web app that generates XML files in php. This XMLs are requested by XMLHttpRequest object (AJAX). Everything works correctly. But today there has been some server upgrade and web app breaks down a little. 
The problem is that in code there are checks related to XMLHttpRequests.
1) if I have a response than I parse it properly based on it content type. 
var contentType = xhr.getResponseHeader("Content-Type"); 
        //build the json object if the response has one
        if(contentType == "application/json") { 
            response = JSON.parse(xhr.responseText); 
        }
        //get the dom element if the response is XML
        else if(contentType == "text/xml") { 
            response = xhr.responseXML; 
        } else { //by default get the response as text
            response = xhr.responseText; 
        }

And here is the problem cause server now returns: 
text/xml;charset=UTF-8

instead of 
text/xml

Ok I can just change this line and the error disappear. But I would like to know why server upgrade (bluehost) can have influance on this. 
This is PHP/MySQL environment. 

A:

Both are valid content types. The content type can be set by the web server software (e.g. Apache) or the script (PHP). I'm assuming it's PHP because of the tag on your question.
If you control the script on the server and want to specify the content type, it's easy to do within PHP by adding the line:  
header('Content-Type: text/xml');

This must occur before any other output is sent from the script because headers appear before content in http responses. If the header is not set within the PHP script, then the web server will choose one instead.
If you don't control the script that produces the XML or the server then you just need to accept that it is common for systems to be upgraded and this may impact on your own application.

