Sha256: 1aa55780f56072aa3ee1300253df7328e786dc1ef0cdb4223439427b38aea9e9

Contents?: true

Size: 1.4 KB

Versions: 17

Compression:

Stored size: 1.4 KB

Contents

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

/**
 * Module requirements.
 */

var HTTPTransport = require('./http');

/**
 * Export the constructor.
 */

exports = module.exports = HTMLFile;

/**
 * HTMLFile transport constructor.
 *
 * @api public
 */

function HTMLFile (mng, data, req) {
  HTTPTransport.call(this, mng, data, req);
};

/**
 * Inherits from Transport.
 */

HTMLFile.prototype.__proto__ = HTTPTransport.prototype;

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

HTMLFile.prototype.name = 'htmlfile';

/**
 * Handles the request.
 *
 * @api private
 */

HTMLFile.prototype.handleRequest = function (req) {
  HTTPTransport.prototype.handleRequest.call(this, req);

  if (req.method == 'GET') {
    req.res.writeHead(200, {
        'Content-Type': 'text/html; charset=UTF-8'
      , 'Connection': 'keep-alive'
      , 'Transfer-Encoding': 'chunked'
    });

    req.res.write(
        '<html><body>'
      + '<script>var _ = function (msg) { parent.s._(msg, document); };</script>'
      + new Array(174).join(' ')
    );
  }
};

/**
 * Performs the write.
 *
 * @api private
 */

HTMLFile.prototype.write = function (data) {
  // escape all forward slashes. see GH-1251
  data = '<script>_(' + JSON.stringify(data).replace(/\//g, '\\/') + ');</script>';

  if (this.response.write(data)) {
    this.drained = true;
  }

  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/htmlfile.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
hooch-0.2.1 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
hooch-0.2.0 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
hooch-0.1.0 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
hooch-0.0.8 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
hooch-0.0.7 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
hooch-0.0.6 jasmine/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/socket.io/lib/transports/htmlfile.js