Search code examples
jqueryajaxinternet-explorer-8cross-domainamplifyjs

xDomain ajax call over https returns 200 in fiddler but throws 404 from jQajax ie8 only


All the facts:

I have a program that communicates with an external system using ajax.

Calls are defined using amplify.js/jq

As I need crossdomain support for IE8 I am using a haxe script which proxies the calls for me and it replaces the xhr object with its shr implementation (SWFHttpRequest):

This xhr object modification is done like this:

amplify.subscribe("request.before.ajax", function (resource, settings, ajaxSettings, xhr) {
        if ($.browser.msie || !!navigator.userAgent.match(/Trident\/7\./)) {
            if (resource.url.indexOf(requestConfig.apiUrl) != -1) {
                var shr = new SWFHttpRequest(); // flash object adds this guy
                ajaxSettings.xhr = function () {
                    return shr;
                };
                ajaxSettings.crossDomain = false;
                ajaxSettings.error = function (e) {
                    var errorDialog = new gDialog({
                        title: "Error",
                        text: "Sorry, but there was an error in requesting information from our servers. Please contact support and provide the following information: response:"
                            + e.responseText + " statusText: "
                            + e.statusText + " status: "
                            + e.status + " from url: " + resource.url
                    })
                };
            }
        }            
    });

Everything works OK in non ie browsers over SSL and Http (no surprise here)

Everything works OK in IE8+ over HTTP and 9+ over HTTPS

In IE8 when over HTTPS the call has this response header:

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json
Expires: -1
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Methods: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Access-Control-Allow-Headers, Content-Type, Accept
X-Powered-By: ASP.NET
Date: Fri, 30 May 2014 10:40:51 GMT
Content-Length: 283

{"ResponseCode":200,"ResponseDescription":"OK","ResponseEntity":"P4w0uZrc2BMOjdLBYF1K2RT9Ku/rTAqDK/2st76YdwhaqGZB/Yw2QCC03ncZJXqDdGYRyty+EDmOwx9MYgZdAtUdfmygjZrD0ST8G/qc4Iwbp7I/r+X5PPbI1QNoiy1VOe7WNgXt7g12UKpRKzXhWvGCUOItA8z1VrsBXLxUtd6p45SmOjrIycKWBVRLPP37cXokvO+uiGuur1p7wF392Q=="}

This is the correct response and I should succeed and go forward but instead ajaxSettings.error tells me:

response:null 
statusText: Not Found 
status: 404 
from url: the correct endpoint url with correct matching protocol

I am not sure what to think or where to look, really confused so any help or clue would be really appreciated.

Please let me know if any further relevant details you may think I should add here.


My clues and thoughts so far:

  1. Could this be related to the IE8 JSON.parse bug?
  2. If it is how would being on https making this problem appear?
  3. This can not have anything to do with the usual bad serializing of json issue as the server response is correctly formed.

Apparently there are some issues on SSL with Microsoft.XMLDOM

So I thought maybe I also include the section of the haxe script which is referencing that:

public function onData( data:String ) {
        if (!this.active) return;
        var stringified = haxe.Json.stringify(haxe.Json.parse(data));
        var striginiedEscaped = StringTools.replace(stringified, "\\", "\\\\");
        ExternalInterface.call( [ "(function(instance, data){",
            "var shr = window.SWFHttpRequest.instances[instance];",
            "if (!shr) return;",
            "shr.status = 200;",
            "shr.statusText = 'OK';",
            "shr.readyState = 4;",
            "shr.responseText = data;",
            "try {",
                "if (window.DOMParser) {",
                    "var dp = new DOMParser();",
                    "shr.responseXML = dp.parseFromString( data, 'text/xml' );",
                "} else {",
                    "shr.responseXML = new ActiveXObject('Microsoft.XMLDOM');",
                    "shr.responseXML.async = 'false';",
                    "shr.responseXML.loadXML(data);",
                "}",
            "} catch(error) { shr.responseXML = null; }",
            "if (shr.onreadystatechange && typeof shr.onreadystatechange=='function') shr.onreadystatechange();",
        "})" ].join(''), this.instance, striginiedEscaped);
    }

According to this page Microsoft.XMLDOM has issues with SSL and I should make sure:

  1. In Internet Explorer, on the Tools menu, click Internet Options. On the Advanced tab, clear the Do not save encrypted pages to disk check box.
  2. Make sure that the server does not send no-cache headers.
  3. In IIS, in the Microsoft Management Console (MMC) snap-in, right-click the XML file. On the HTTP Headers tab, turn off the Content-Expiration option.

Has anyone dealt with this issue before? Will be applying these and report back.


Solution

  • Ok, Thought I add the answer if there is still another soul in this day and age who has to deal with this.

    This indeed was: Microsoft.XMLDOM has issues with SSL

    this does the job:

    1. clear the Do not save encrypted pages to disk check box in IE
    
    2. Cache-Control: no-transform,public,max-age=300,s-maxage=900