raspberryGPIOhtmlserver/node_modules/engine.io-client/lib/xmlhttprequest.js
node_modules/engine.io-client/lib/xmlhttprequest.jsRaw
1// browser shim for xmlhttprequest module
2var hasCORS = require('has-cors');
3
4module.exports = function(opts) {
5 var xdomain = opts.xdomain;
6
7 // scheme must be same when usign XDomainRequest
8 // http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
9 var xscheme = opts.xscheme;
10
11 // XDomainRequest has a flow of not sending cookie, therefore it should be disabled as a default.
12 // https://github.com/Automattic/engine.io-client/pull/217
13 var enablesXDR = opts.enablesXDR;
14
15 // XMLHttpRequest can be disabled on IE
16 try {
17 if ('undefined' != typeof XMLHttpRequest && (!xdomain || hasCORS)) {
18 return new XMLHttpRequest();
19 }
20 } catch (e) { }
21
22 // Use XDomainRequest for IE8 if enablesXDR is true
23 // because loading bar keeps flashing when using jsonp-polling
24 // https://github.com/yujiosaka/socke.io-ie8-loading-example
25 try {
26 if ('undefined' != typeof XDomainRequest && !xscheme && enablesXDR) {
27 return new XDomainRequest();
28 }
29 } catch (e) { }
30
31 if (!xdomain) {
32 try {
33 return new ActiveXObject('Microsoft.XMLHTTP');
34 } catch(e) { }
35 }
36}