Sha256: f0102aeef2938d3d877c7de5320e7b9967c6c23ae5ec4cf426d39ab7d660040f

Contents?: true

Size: 1.25 KB

Versions: 17

Compression:

Stored size: 1.25 KB

Contents

/*!
 * socket.io-node
 * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
 * MIT Licensed
 */

/**
 * Module requirements.
 */

var HTTPPolling = require('./http-polling');

/**
 * Export the constructor.
 */

exports = module.exports = XHRPolling;

/**
 * Ajax polling transport.
 *
 * @api public
 */

function XHRPolling (mng, data, req) {
  HTTPPolling.call(this, mng, data, req);
};

/**
 * Inherits from Transport.
 */

XHRPolling.prototype.__proto__ = HTTPPolling.prototype;

/**
 * Transport name
 *
 * @api public
 */

XHRPolling.prototype.name = 'xhr-polling';

/**
 * Frames data prior to write.
 *
 * @api private
 */

XHRPolling.prototype.doWrite = function (data) {
  HTTPPolling.prototype.doWrite.call(this);

  var origin = this.req.headers.origin
    , headers = {
          'Content-Type': 'text/plain; charset=UTF-8'
        , 'Content-Length': data === undefined ? 0 : Buffer.byteLength(data)
        , 'Connection': 'Keep-Alive'
      };

  if (origin) {
    // https://developer.mozilla.org/En/HTTP_Access_Control
    headers['Access-Control-Allow-Origin'] = origin;
    headers['Access-Control-Allow-Credentials'] = 'true';
  }

  this.response.writeHead(200, headers);
  this.response.write(data);
  this.log.debug(this.name + ' writing', data);
};

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
hooch-0.2.1 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
hooch-0.2.0 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
hooch-0.1.0 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
hooch-0.0.8 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
hooch-0.0.7 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
hooch-0.0.6 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/transports/xhr-polling.js