comparison node_modules/socket.io/lib/transports/xhr-polling.js @ 69:333afcfd3f3a

added node_modules to project and fixed path to chronometer also added deps to installer script
author tzara <rc-web@kiben.net>
date Sat, 26 Oct 2013 14:12:50 +0100
parents
children
comparison
equal deleted inserted replaced
68:b076cd17638c 69:333afcfd3f3a
1
2 /*!
3 * socket.io-node
4 * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
5 * MIT Licensed
6 */
7
8 /**
9 * Module requirements.
10 */
11
12 var HTTPPolling = require('./http-polling');
13
14 /**
15 * Export the constructor.
16 */
17
18 exports = module.exports = XHRPolling;
19
20 /**
21 * Ajax polling transport.
22 *
23 * @api public
24 */
25
26 function XHRPolling (mng, data, req) {
27 HTTPPolling.call(this, mng, data, req);
28 };
29
30 /**
31 * Inherits from Transport.
32 */
33
34 XHRPolling.prototype.__proto__ = HTTPPolling.prototype;
35
36 /**
37 * Transport name
38 *
39 * @api public
40 */
41
42 XHRPolling.prototype.name = 'xhr-polling';
43
44 /**
45 * Frames data prior to write.
46 *
47 * @api private
48 */
49
50 XHRPolling.prototype.doWrite = function (data) {
51 HTTPPolling.prototype.doWrite.call(this);
52
53 var origin = this.req.headers.origin
54 , headers = {
55 'Content-Type': 'text/plain; charset=UTF-8'
56 , 'Content-Length': data === undefined ? 0 : Buffer.byteLength(data)
57 , 'Connection': 'Keep-Alive'
58 };
59
60 if (origin) {
61 // https://developer.mozilla.org/En/HTTP_Access_Control
62 headers['Access-Control-Allow-Origin'] = origin;
63 headers['Access-Control-Allow-Credentials'] = 'true';
64 }
65
66 this.response.writeHead(200, headers);
67 this.response.write(data);
68 this.log.debug(this.name + ' writing', data);
69 };