Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE9 XMLHTTPRequest request body incomplete but readyState=4 statuscode=200

I have an issue in IE9 where the request body of an XMLHTTPRequest is incomplete.

The code that handles the XMLHTTPRequest waits for readyState=4, then checks statuscode=200. It will then proceed to JSON.parse but that fails because the request body is incomplete. When I inspect the request body I can clearly see that it's cut-off at some point in the string, like in the middle of a property.

Server-side there is very little to check, it's just a matter of echo json_encode($reply);

I know AJAX errors can come from a wide range of sources, like: over-eager firewalls, but that would be accompanied by a proper status like (like 403). In this case the XMLHTTPRequest response seems to think everything is fine so I don't know how to detect it. Is there another property I can check, or does IE9 perhaps cut off long response bodies?

I will continue to investigate this, but as I can't not reproduce it myself this may take a couple of days.

Can anyone confirm these issues and perhaps point me to a solution?

Note: This only seems to occur in IE9, I suppose that's because older versions don't use XMLHTTPRequest but ActiveXObject. This does not occur in Chrome or Firefox, at least: I haven't seen it.

like image 507
Halcyon Avatar asked Nov 14 '22 00:11

Halcyon


1 Answers

It sounds like your HTTP response headers include a Content-Length header that claims the JSON body is shorter then it really is.

Check if this is the case, find out where it is being added and correct it or remove it.

like image 142
Quentin Avatar answered Nov 15 '22 13:11

Quentin