sockjs/sockjs-client — pull request #155 by danielstjules (2014-02-19 14:38:22+00:00)
Title: Fix #79, avoid using XDRObject when connecting across schemes

This is a PR in reference to https://github.com/sockjs/sockjs-client/issues/79

Currently, IE8 and IE9 can't connect from http to a SockJS server using SSL. This is due to XDRObjects enforcing that requests use the same scheme as the hosting page. Simply excluding `xdr-streaming` and `xdr-polling` from the `protocols_whitelist` doesn't work since IE8/9 will always use an XDRObject when creating an InfoReceiver.

I understand that forcing the client to use `jsonp-polling` as the default transport in this case might not be ideal. As @majek hinted to in the comment thread, someone might want to avoid supporting http -> https. However, I think it would be nice to have the option, since it's supported with all other browser and transports. And with this PR, a user could handle this behaviour by simply editing the protocols_whitelist, e.g.

``` js
var options = {};

if (location.protocol === 'http:') {
// Enable http->https requests in IE8/9 by excluding xdr-streaming and xdr-polling
options.protocols_whitelist = ['websocket', 'xhr-streaming', 'iframe-eventsource',
'iframe-htmlfile', 'xhr-polling', 'iframe-xhr-polling', 'jsonp-polling'];
}

var sockjs = new SockJS(url, null, options);
```

Thanks!