4 * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
12 var HTTPTransport = require('./http');
15 * Export the constructor.
18 exports = module.exports = HTMLFile;
21 * HTMLFile transport constructor.
26 function HTMLFile (mng, data, req) {
27 HTTPTransport.call(this, mng, data, req);
31 * Inherits from Transport.
34 HTMLFile.prototype.__proto__ = HTTPTransport.prototype;
42 HTMLFile.prototype.name = 'htmlfile';
45 * Handles the request.
50 HTMLFile.prototype.handleRequest = function (req) {
51 HTTPTransport.prototype.handleRequest.call(this, req);
53 if (req.method == 'GET') {
54 req.res.writeHead(200, {
55 'Content-Type': 'text/html; charset=UTF-8'
56 , 'Connection': 'keep-alive'
57 , 'Transfer-Encoding': 'chunked'
62 + '<script>var _ = function (msg) { parent.s._(msg, document); };</script>'
63 + new Array(174).join(' ')
74 HTMLFile.prototype.write = function (data) {
75 // escape all forward slashes. see GH-1251
76 data = '<script>_(' + JSON.stringify(data).replace(/\//g, '\\/') + ');</script>';
78 if (this.response.write(data)) {
82 this.log.debug(this.name + ' writing', data);