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 HTTPTransport = require('./http'); rc-web@69: rc-web@69: /** rc-web@69: * Export the constructor. rc-web@69: */ rc-web@69: rc-web@69: exports = module.exports = HTMLFile; rc-web@69: rc-web@69: /** rc-web@69: * HTMLFile transport constructor. rc-web@69: * rc-web@69: * @api public rc-web@69: */ rc-web@69: rc-web@69: function HTMLFile (mng, data, req) { rc-web@69: HTTPTransport.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: HTMLFile.prototype.__proto__ = HTTPTransport.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: HTMLFile.prototype.name = 'htmlfile'; rc-web@69: rc-web@69: /** rc-web@69: * Handles the request. rc-web@69: * rc-web@69: * @api private rc-web@69: */ rc-web@69: rc-web@69: HTMLFile.prototype.handleRequest = function (req) { rc-web@69: HTTPTransport.prototype.handleRequest.call(this, req); rc-web@69: rc-web@69: if (req.method == 'GET') { rc-web@69: req.res.writeHead(200, { rc-web@69: 'Content-Type': 'text/html; charset=UTF-8' rc-web@69: , 'Connection': 'keep-alive' rc-web@69: , 'Transfer-Encoding': 'chunked' rc-web@69: }); rc-web@69: rc-web@69: req.res.write( rc-web@69: '' rc-web@69: + '' rc-web@69: + new Array(174).join(' ') rc-web@69: ); rc-web@69: } rc-web@69: }; rc-web@69: rc-web@69: /** rc-web@69: * Performs the write. rc-web@69: * rc-web@69: * @api private rc-web@69: */ rc-web@69: rc-web@69: HTMLFile.prototype.write = function (data) { rc-web@69: // escape all forward slashes. see GH-1251 rc-web@69: data = ''; rc-web@69: rc-web@69: if (this.response.write(data)) { rc-web@69: this.drained = true; rc-web@69: } rc-web@69: rc-web@69: this.log.debug(this.name + ' writing', data); rc-web@69: };