From cf4ebc2a5080bc6decc8376ed0d59175f9eb2010 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 4 Apr 2013 20:34:14 +0300 Subject: Use fallback transport if websockets is not supported by server (#11491 Applied fix from GitHub Atmosphere project: https://github.com/Atmosphere/atmosphere/commit/367a88d340910ef5fda702d1467fbbba1dec6907 Change-Id: Ieae27cab5a8637886a66f923184b52ce1e0ed661 --- WebContent/VAADIN/atmosphere.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebContent/VAADIN/atmosphere.min.js b/WebContent/VAADIN/atmosphere.min.js index 64f6604951..83249782b6 100644 --- a/WebContent/VAADIN/atmosphere.min.js +++ b/WebContent/VAADIN/atmosphere.min.js @@ -9,4 +9,4 @@ * Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -(function(){function l(a,b){var c,f,g=b.headers||{};if(b.readResponsesHeaders)for(c in b.lastTimestamp=(a.getResponseHeader("X-Cache-Date")||"").split(" ").pop(),b.uuid=(a.getResponseHeader("X-Atmosphere-tracking-id")||"").split(" ").pop(),g)(f=a.getResponseHeader(c))&&(g[c]=f)}function m(a,b){var c,f,g=b.headers||{};b.dropAtmosphereHeaders||(a.setRequestHeader("X-Atmosphere-Framework",n),a.setRequestHeader("X-Atmosphere-Transport",b.transport),a.setRequestHeader("X-Cache-Date",b.lastTimestamp||0), b.trackMessageLength&&a.setRequestHeader("X-Atmosphere-TrackMessageSize","true"),b.contentType&&a.setRequestHeader("Content-Type",b.contentType),a.setRequestHeader("X-Atmosphere-tracking-id",b.uuid));for(c in g)f=g[c],(f=portal.support.isFunction(f)?f.call(null,a,b):f)&&a.setRequestHeader(c,f)}var n="1.1",k={},p=portal.support.now();k.subscribe=function(a){a=new k.AtmosphereRequest(a);a.open();return a};k.unsubscribe=portal.finalize;k.AtmosphereRequest=function(a){var b,c;a=portal.support.extend({url:"", connectTimeout:-1,reconnectInterval:0,timeout:3E5,method:"GET",fallbackMethod:"GET",headers:{},maxRequest:-1,transport:"long-polling",fallbackTransport:"streaming",dispatchUrl:null,webSocketPathDelimiter:"@@",webSocketBinaryType:null,enableXDR:!1,rewriteURL:!1,attachHeadersAsQueryString:!0,withCredentials:!1,trackMessageLength:!1,messageDelimiter:"|",shared:!1,lastTimestamp:0,readResponsesHeaders:!0,dropAtmosphereHeaders:!0,contentType:"",uuid:0,executeCallbackBeforeReconnect:!1},a);this.open=function(){function f(){g(); j=setTimeout(function(){b.fire("close","idletimeout")},a.timeout)}function g(){clearTimeout(j)}function h(a){return{"long-polling":"longpoll",streaming:"stream",jsonp:"longpolljsonp",sse:"sse",websocket:"ws",session:"session",test:"test"}[a]}var j;b=portal.open(a.url,{atrequest:a,method:a.method,transports:[h(a.transport)],timeout:a.connectTimeout,credentials:a.withCredentials,sharing:a.shared,params:a.headers,longpollTest:!1,urlBuilder:function(b,d){if(!a.attachHeadersAsQueryString)return b;delete d.id; delete d.transport;delete d.heartbeat;delete d.lastEventId;portal.support.extend(d,{"X-Atmosphere-tracking-id":a.uuid,"X-Atmosphere-Framework":n,"X-Atmosphere-Transport":a.transport,"X-Cache-Date":a.lastTimestamp||0});a.trackMessageLength&&(d["X-Atmosphere-TrackMessageSize"]=!0);a.contentType&&(d["Content-Type"]=a.contentType);return b+(/\?/.test(b)?"&":"?")+portal.support.param(d)},reconnect:function(b,d){return-1===a.maxRequest||d')",a.insertBefore(b,a.firstChild),a.removeChild(b)}});b.on({connecting:function(){b.data("t1", {ws:"websocket",sse:"sse",streamxhr:"streaming",streamxdr:"streaming",streamiframe:"streaming",longpollajax:"long-polling",longpollxdr:"long-polling",longpolljsonp:"jsonp",session:"session",test:"test"}[b.data("transport")])},open:function(){var e={status:200,responseBody:"",headers:[],state:"messageReceived",transport:b.data("t1"),error:null,request:a};0';d.firstChild.value=b;portal.support.on(d.lastChild,"load",function(){document.body.removeChild(d);c()});document.body.appendChild(d);d.submit()};return{send:function(a){h.push(a); g||(g=!0,c())}}},streamxhr:function(a,b){var c;if(!(portal.support.browser.msie&&10>+portal.support.browser.version||b.crossDomain&&!portal.support.corsable))return portal.support.extend(portal.transports.httpbase(a,b),{open:function(){var f;c=portal.support.xhr();c.onreadystatechange=function(){function g(){var b=a.data("index"),f=c.responseText.length;b?f>b&&a._fire(c.responseText.substring(b,f),!0):a.fire("open")._fire(c.responseText,!0);a.data("index",f)}2===c.readyState?l(c,b.atrequest):3=== c.readyState&&200===c.status?portal.support.browser.opera&&!f?f=portal.support.iterate(g):g():4===c.readyState&&(f&&f(),a.fire("close",200===c.status?"done":"error"))};c.open("GET",a.data("url"));portal.support.corsable&&(c.withCredentials=b.credentials);m(c,b.atrequest);c.send(null)},close:function(){c.abort()}})},longpollajax:function(a,b){var c,f,g=0;if(!b.crossDomain||portal.support.corsable)return portal.support.extend(portal.transports.httpbase(a,b),{open:function(){function h(){var j=a.buildURL(!g? "open":"poll",{count:++g});a.data("url",j);c=portal.support.xhr();c.onreadystatechange=function(){var e;!f&&4===c.readyState&&(200===c.status?(l(c,b.atrequest),(e=c.responseText)||1===g?(1===g&&a.fire("open"),e&&a._fire(e),h()):a.fire("close","done")):a.fire("close","error"))};c.open("GET",j);m(c,b.atrequest);portal.support.corsable&&(c.withCredentials=b.credentials);c.send(null)}b.longpollTest?h():setTimeout(function(){a.fire("open");h()},50)},close:function(){f=!0;c.abort()}})}});portal.support.on(window, "keypress",function(a){27===a.which&&a.preventDefault()});window.atmosphere=k})(); \ No newline at end of file +(function(){function l(a,b){var c,f,g=b.headers||{};if(b.readResponsesHeaders)for(c in b.lastTimestamp=(a.getResponseHeader("X-Cache-Date")||"").split(" ").pop(),b.uuid=(a.getResponseHeader("X-Atmosphere-tracking-id")||"").split(" ").pop(),g)(f=a.getResponseHeader(c))&&(g[c]=f)}function m(a,b){var c,f,g=b.headers||{};b.dropAtmosphereHeaders||(a.setRequestHeader("X-Atmosphere-Framework",n),a.setRequestHeader("X-Atmosphere-Transport",b.transport),a.setRequestHeader("X-Cache-Date",b.lastTimestamp||0), b.trackMessageLength&&a.setRequestHeader("X-Atmosphere-TrackMessageSize","true"),b.contentType&&a.setRequestHeader("Content-Type",b.contentType),a.setRequestHeader("X-Atmosphere-tracking-id",b.uuid));for(c in g)f=g[c],(f=portal.support.isFunction(f)?f.call(null,a,b):f)&&a.setRequestHeader(c,f)}var n="1.1",k={},p=portal.support.now();k.subscribe=function(a){a=new k.AtmosphereRequest(a);a.open();return a};k.unsubscribe=portal.finalize;k.AtmosphereRequest=function(a){var b,c;a=portal.support.extend({url:"", connectTimeout:-1,reconnectInterval:0,timeout:3E5,method:"GET",fallbackMethod:"GET",headers:{},maxRequest:-1,transport:"long-polling",fallbackTransport:"streaming",dispatchUrl:null,webSocketPathDelimiter:"@@",webSocketBinaryType:null,enableXDR:!1,rewriteURL:!1,attachHeadersAsQueryString:!0,withCredentials:!1,trackMessageLength:!1,messageDelimiter:"|",shared:!1,lastTimestamp:0,readResponsesHeaders:!0,dropAtmosphereHeaders:!0,contentType:"",uuid:0,executeCallbackBeforeReconnect:!1},a);this.open=function(){function f(){g(); j=setTimeout(function(){b.fire("close","idletimeout")},a.timeout)}function g(){clearTimeout(j)}function h(a){return{"long-polling":"longpoll",streaming:"stream",jsonp:"longpolljsonp",sse:"sse",websocket:"ws",session:"session",test:"test"}[a]}var j;b=portal.open(a.url,{atrequest:a,method:a.method,transports:[h(a.transport)],timeout:a.connectTimeout,credentials:a.withCredentials,sharing:a.shared,params:a.headers,longpollTest:!1,urlBuilder:function(b,d){if(!a.attachHeadersAsQueryString)return b;delete d.id; delete d.transport;delete d.heartbeat;delete d.lastEventId;portal.support.extend(d,{"X-Atmosphere-tracking-id":a.uuid,"X-Atmosphere-Framework":n,"X-Atmosphere-Transport":a.transport,"X-Cache-Date":a.lastTimestamp||0});a.trackMessageLength&&(d["X-Atmosphere-TrackMessageSize"]=!0);a.contentType&&(d["Content-Type"]=a.contentType);return b+(/\?/.test(b)?"&":"?")+portal.support.param(d)},reconnect:function(b,d){return-1===a.maxRequest||d')",a.insertBefore(b,a.firstChild),a.removeChild(b)}});b.on({connecting:function(){b.data("t1", {ws:"websocket",sse:"sse",streamxhr:"streaming",streamxdr:"streaming",streamiframe:"streaming",longpollajax:"long-polling",longpollxdr:"long-polling",longpolljsonp:"jsonp",session:"session",test:"test"}[b.data("transport")])},open:function(){var e={status:200,responseBody:"",headers:[],state:"messageReceived",transport:b.data("t1"),error:null,request:a};0';d.firstChild.value=b;portal.support.on(d.lastChild,"load",function(){document.body.removeChild(d);c()});document.body.appendChild(d);d.submit()};return{send:function(a){h.push(a); g||(g=!0,c())}}},streamxhr:function(a,b){var c;if(!(portal.support.browser.msie&&10>+portal.support.browser.version||b.crossDomain&&!portal.support.corsable))return portal.support.extend(portal.transports.httpbase(a,b),{open:function(){var f;c=portal.support.xhr();c.onreadystatechange=function(){function g(){var b=a.data("index"),f=c.responseText.length;b?f>b&&a._fire(c.responseText.substring(b,f),!0):a.fire("open")._fire(c.responseText,!0);a.data("index",f)}2===c.readyState?l(c,b.atrequest):3=== c.readyState&&200===c.status?portal.support.browser.opera&&!f?f=portal.support.iterate(g):g():4===c.readyState&&(f&&f(),a.fire("close",200===c.status?"done":"error"))};c.open("GET",a.data("url"));portal.support.corsable&&(c.withCredentials=b.credentials);m(c,b.atrequest);c.send(null)},close:function(){c.abort()}})},longpollajax:function(a,b){var c,f,g=0;if(!b.crossDomain||portal.support.corsable)return portal.support.extend(portal.transports.httpbase(a,b),{open:function(){function h(){var j=a.buildURL(!g? "open":"poll",{count:++g});a.data("url",j);c=portal.support.xhr();c.onreadystatechange=function(){var e;!f&&4===c.readyState&&(200===c.status?(l(c,b.atrequest),(e=c.responseText)||1===g?(1===g&&a.fire("open"),e&&a._fire(e),h()):a.fire("close","done")):a.fire("close","error"))};c.open("GET",j);m(c,b.atrequest);portal.support.corsable&&(c.withCredentials=b.credentials);c.send(null)}b.longpollTest?h():setTimeout(function(){a.fire("open");h()},50)},close:function(){f=!0;c.abort()}})}});portal.support.on(window, "keypress",function(a){27===a.which&&a.preventDefault()});window.atmosphere=k})(); \ No newline at end of file -- cgit v1.2.3