rc-web@69: rc-web@69: /*! rc-web@69: * socket.io-node rc-web@69: * Copyright(c) 2011 LearnBoost rc-web@69: * MIT Licensed rc-web@69: */ rc-web@69: rc-web@69: /** rc-web@69: * Module requirements. rc-web@69: */ rc-web@69: rc-web@69: var HTTPPolling = require('./http-polling'); rc-web@69: rc-web@69: /** rc-web@69: * Export the constructor. rc-web@69: */ rc-web@69: rc-web@69: exports = module.exports = XHRPolling; rc-web@69: rc-web@69: /** rc-web@69: * Ajax polling transport. rc-web@69: * rc-web@69: * @api public rc-web@69: */ rc-web@69: rc-web@69: function XHRPolling (mng, data, req) { rc-web@69: HTTPPolling.call(this, mng, data, req); rc-web@69: }; rc-web@69: rc-web@69: /** rc-web@69: * Inherits from Transport. rc-web@69: */ rc-web@69: rc-web@69: XHRPolling.prototype.__proto__ = HTTPPolling.prototype; rc-web@69: rc-web@69: /** rc-web@69: * Transport name rc-web@69: * rc-web@69: * @api public rc-web@69: */ rc-web@69: rc-web@69: XHRPolling.prototype.name = 'xhr-polling'; rc-web@69: rc-web@69: /** rc-web@69: * Frames data prior to write. rc-web@69: * rc-web@69: * @api private rc-web@69: */ rc-web@69: rc-web@69: XHRPolling.prototype.doWrite = function (data) { rc-web@69: HTTPPolling.prototype.doWrite.call(this); rc-web@69: rc-web@69: var origin = this.req.headers.origin rc-web@69: , headers = { rc-web@69: 'Content-Type': 'text/plain; charset=UTF-8' rc-web@69: , 'Content-Length': data === undefined ? 0 : Buffer.byteLength(data) rc-web@69: , 'Connection': 'Keep-Alive' rc-web@69: }; rc-web@69: rc-web@69: if (origin) { rc-web@69: // https://developer.mozilla.org/En/HTTP_Access_Control rc-web@69: headers['Access-Control-Allow-Origin'] = origin; rc-web@69: headers['Access-Control-Allow-Credentials'] = 'true'; rc-web@69: } rc-web@69: rc-web@69: this.response.writeHead(200, headers); rc-web@69: this.response.write(data); rc-web@69: this.log.debug(this.name + ' writing', data); rc-web@69: };