Last change
on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
894 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var 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 | ;
|
---|
9 |
|
---|
10 | function XhrPollingTransport(transUrl) {
|
---|
11 | if (!XHRLocalObject.enabled && !XHRCorsObject.enabled) {
|
---|
12 | throw new Error('Transport created when disabled');
|
---|
13 | }
|
---|
14 | AjaxBasedTransport.call(this, transUrl, '/xhr', XhrReceiver, XHRCorsObject);
|
---|
15 | }
|
---|
16 |
|
---|
17 | inherits(XhrPollingTransport, AjaxBasedTransport);
|
---|
18 |
|
---|
19 | XhrPollingTransport.enabled = function(info) {
|
---|
20 | if (info.nullOrigin) {
|
---|
21 | return false;
|
---|
22 | }
|
---|
23 |
|
---|
24 | if (XHRLocalObject.enabled && info.sameOrigin) {
|
---|
25 | return true;
|
---|
26 | }
|
---|
27 | return XHRCorsObject.enabled;
|
---|
28 | };
|
---|
29 |
|
---|
30 | XhrPollingTransport.transportName = 'xhr-polling';
|
---|
31 | XhrPollingTransport.roundTrips = 2; // preflight, ajax
|
---|
32 |
|
---|
33 | module.exports = XhrPollingTransport;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.