wandenberg / nginx-push-stream-module

A pure stream http push technology for your Nginx setup. Comet made easy and really scalable.
Other
2.22k stars 295 forks source link

Cross-domain stream on IE8 doesn't work. #88

Closed tingwind closed 9 years ago

tingwind commented 11 years ago

On IE8 posting a cross-domain request needs using "XDomainRequest" object, but IE8 contains both "XMLHttpRequest" and "XDomainRequest", now let's have a look in the code

var Ajax = {
    _getXHRObject : function() {
      var xhr = false;
      try { xhr = new window.XMLHttpRequest(); }
      catch (e1) {
        try { xhr = new window.XDomainRequest(); }
        catch (e2) {
          try { xhr = new window.ActiveXObject("Msxml2.XMLHTTP"); }
          catch (e3) {
            try { xhr = new window.ActiveXObject("Microsoft.XMLHTTP"); }
            catch (e4) {
              xhr = false;
            }
          }
        }
      }
      return xhr;
    },

So actually XDomainRequest instance will never be created. In the following part we see this

      if (post) {
        xhr.setRequestHeader("Accept", "application/json");
        xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      }

but XDomainRequest on IE8 doesn't support these two methods.

I modified these snippets then cross-domain stream on ie8 works, I am not sure this is a bug or is there any thing i have missed ?

wandenberg commented 11 years ago

Hi,

can you send me your configuration and a small html/js which reproduce the problem. I'm not sure but POST should not have crossdomain issues, but I will test asap

cnscud commented 11 years ago

after my test, it is not work under ie8, when crossdomain. it is just javascript issue, just same with chat.html but change:

for example: the html url is: http://a.test.com/examples/chat.html

the js part:

var pushstream = new PushStream({ host: "b.test.com", port: 9080, modes: "websocket|eventsource|stream" });

tingwind commented 11 years ago

Sorry for responsing so late. days ago i am not clearly understand how your code working, now i am very sure this is a pure ajax CORS problem, there is none business to communicate mode choosed, sorry for my misunderstanding. It happens at sendMessage, sendMessage only has two situations websocket or not socket. Not scoket both use Ajax to post message. About CORS problem i suppose i have described clearly in first post. at last thanks a lot for your great work, this module works fine on our project.