diff --git a/lib/transports/jsonp-polling.js b/lib/transports/jsonp-polling.js index 6f6829f78..f2d0cb221 100644 --- a/lib/transports/jsonp-polling.js +++ b/lib/transports/jsonp-polling.js @@ -8,20 +8,20 @@ (function(){ var io = this.io; - + io.JSONP = []; - + JSONPPolling = io.Transport['jsonp-polling'] = function(){ io.Transport.XHR.apply(this, arguments); this._insertAt = document.getElementsByTagName('script')[0]; this._index = io.JSONP.length; io.JSONP.push(this); }; - + io.util.inherit(JSONPPolling, io.Transport['xhr-polling']); - + JSONPPolling.prototype.type = 'jsonp-polling'; - + JSONPPolling.prototype._send = function(data){ var self = this; if (!('_form' in this)){ @@ -29,7 +29,7 @@ area = document.createElement('TEXTAREA'), id = this._iframeId = 'socket_io_iframe_' + this._index, iframe; - + form.style.position = 'absolute'; form.style.top = '-1000px'; form.style.left = '-1000px'; @@ -38,24 +38,34 @@ form.action = this._prepareUrl() + '/' + (+new Date) + '/' + this._index; area.name = 'data'; form.appendChild(area); + //Tornado + secureCookie = io.util.getCookie('_xsrf'); + if (secureCookie) { + input = document.createElement('input'); + input.type = 'hidden'; + input.name = '_xsrf'; + input.value = secureCookie; + form.appendChild(input); + } + this._insertAt.parentNode.insertBefore(form, this._insertAt); document.body.appendChild(form); - + this._form = form; this._area = area; } - + function complete(){ initIframe(); self._posting = false; self._checkSend(); }; - + function initIframe(){ if (self._iframe){ self._form.removeChild(self._iframe); - } - + } + try { // ie6 dynamic iframes with target="" support (thanks Chris Lambacher) iframe = document.createElement('