Working around the IE9/IE8 XDR Post bug

When creating a REST-API for a client we ran across this really weird problem.

IE8/IE9 can’t make XMLHttpRequest to other domains via CORS. Microsoft invented their own solution for this problem, called XDR. The problem with XDR is that it doesn’t send a Content-type when doing POST requests, defaulting this value to “text/plain” instead.

PHP populates the $_POST array with data, only when the Content-type is set to “application/x-www-form-urlencoded” or “multipart/form-data”. So $_POST is just an empty array, unless you make some kind of workaround.

Here’s a stripped down version on how we solved it.

if(stristr($_SERVER['HTTP_USER_AGENT'], ' MSIE 9')){
	$msie_post = file_get_contents("php://input");
	parse_str($msie_post, $_POST);

One thought on “Working around the IE9/IE8 XDR Post bug

Comments are closed.