source: trip-planner-front/node_modules/sockjs-client/lib/transport/xhr-streaming.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1'use strict';
2
3var inherits = require('inherits')
4 , AjaxBasedTransport = require('./lib/ajax-based')
5 , XhrReceiver = require('./receiver/xhr')
6 , XHRCorsObject = require('./sender/xhr-cors')
7 , XHRLocalObject = require('./sender/xhr-local')
8 , browser = require('../utils/browser')
9 ;
10
11function XhrStreamingTransport(transUrl) {
12 if (!XHRLocalObject.enabled && !XHRCorsObject.enabled) {
13 throw new Error('Transport created when disabled');
14 }
15 AjaxBasedTransport.call(this, transUrl, '/xhr_streaming', XhrReceiver, XHRCorsObject);
16}
17
18inherits(XhrStreamingTransport, AjaxBasedTransport);
19
20XhrStreamingTransport.enabled = function(info) {
21 if (info.nullOrigin) {
22 return false;
23 }
24 // Opera doesn't support xhr-streaming #60
25 // But it might be able to #92
26 if (browser.isOpera()) {
27 return false;
28 }
29
30 return XHRCorsObject.enabled;
31};
32
33XhrStreamingTransport.transportName = 'xhr-streaming';
34XhrStreamingTransport.roundTrips = 2; // preflight, ajax
35
36// Safari gets confused when a streaming ajax request is started
37// before onload. This causes the load indicator to spin indefinetely.
38// Only require body when used in a browser
39XhrStreamingTransport.needBody = !!global.document;
40
41module.exports = XhrStreamingTransport;
Note: See TracBrowser for help on using the repository browser.