1234567891011121314151617181920212223242526272829303132 |
- 'use strict';
- var inherits = require('inherits')
- , AjaxBasedTransport = require('./lib/ajax-based')
- , XhrReceiver = require('./receiver/xhr')
- , XDRObject = require('./sender/xdr')
- ;
- // According to:
- // http://stackoverflow.com/questions/1641507/detect-browser-support-for-cross-domain-xmlhttprequests
- // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
- function XdrStreamingTransport(transUrl) {
- if (!XDRObject.enabled) {
- throw new Error('Transport created when disabled');
- }
- AjaxBasedTransport.call(this, transUrl, '/xhr_streaming', XhrReceiver, XDRObject);
- }
- inherits(XdrStreamingTransport, AjaxBasedTransport);
- XdrStreamingTransport.enabled = function(info) {
- if (info.cookie_needed || info.nullOrigin) {
- return false;
- }
- return XDRObject.enabled && info.sameScheme;
- };
- XdrStreamingTransport.transportName = 'xdr-streaming';
- XdrStreamingTransport.roundTrips = 2; // preflight, ajax
- module.exports = XdrStreamingTransport;
|