Issue - NodeJS support for CometD client.
Small changes to make cometd.js friendlier in a NodeJS environment.
try {
var state = xhr.readyState;
xhr.abort();
- return state !== XMLHttpRequest.UNSENT;
+ return state !== window.XMLHttpRequest.UNSENT;
} catch (x) {
this._debug(x);
}
};
_self.xhrSend = function(packet) {
- var xhr = new XMLHttpRequest();
+ var xhr = new window.XMLHttpRequest();
xhr.withCredentials = true;
xhr.open('POST', packet.url, packet.sync !== true);
var headers = packet.headers;
* @return whether the given hostAndPort is cross domain
*/
this._isCrossDomain = function(hostAndPort) {
- return hostAndPort && hostAndPort !== window.location.host;
+ if (window.location && window.location.host) {
+ if (hostAndPort) {
+ return hostAndPort !== window.location.host;
+ }
+ }
+ return false;
};
function _configure(configuration) {
