view release on metacpan or search on metacpan
socialcalc/third-party/Socket.IO-node/lib/socket.io/client.js view on Meta::CPAN
this._writeQueue = this._writeQueue || [];
this._writeQueue.push(message);
return this;
};
Client.prototype._generateSessionId = function(){
this.sessionId = Math.random().toString().substr(2);
return this;
};
Client.prototype._verifyOrigin = function(origin){
var origins = this.listener.options.origins;
if (origins.indexOf('*:*') !== -1) {
return true;
}
if (origin) {
try {
var parts = urlparse(origin);
return origins.indexOf(parts.host + ':' + parts.port) !== -1 ||
origins.indexOf(parts.host + ':*') !== -1 ||
origins.indexOf('*:' + parts.port) !== -1;
socialcalc/third-party/Socket.IO-node/lib/socket.io/transports/jsonp-polling.js view on Meta::CPAN
};
};
JSONPPolling.prototype._onConnect = function(req, res){
this._index = req.url.match(/\/([0-9]+)\/?$/).pop();
XHRPolling.prototype._onConnect.call(this, req, res);
};
JSONPPolling.prototype._write = function(message){
if (this._open){
if (this.request.headers.origin && !this._verifyOrigin(this.request.headers.origin)){
message = "alert('Cross domain security restrictions not met');";
} else {
message = "io.JSONP["+ this._index +"]._("+ JSON.stringify(message) +");";
}
this.response.writeHead(200, {'Content-Type': 'text/javascript; charset=UTF-8', 'Content-Length': Buffer.byteLength(message)});
this.response.write(message);
this.response.end();
this._onClose();
}
};
socialcalc/third-party/Socket.IO-node/lib/socket.io/transports/websocket.js view on Meta::CPAN
req.connection.end();
return false;
}
this.parser = new Parser();
this.parser.on('data', self._onMessage.bind(this));
this.parser.on('error', self._onClose.bind(this));
Client.prototype._onConnect.call(this, req);
if (this.request.headers.upgrade !== 'WebSocket' || !this._verifyOrigin(this.request.headers.origin)){
this.listener.options.log('WebSocket connection invalid or Origin not verified');
this._onClose();
return false;
}
var origin = this.request.headers.origin,
location = (this.request.socket.encrypted ? 'wss' : 'ws')
+ '://' + this.request.headers.host + this.request.url;
this.waitingForNonce = false;
socialcalc/third-party/Socket.IO-node/lib/socket.io/transports/xhr-multipart.js view on Meta::CPAN
var Multipart = module.exports = function(){
Client.apply(this, arguments);
};
util.inherits(Multipart, Client);
Multipart.prototype._onConnect = function(req, res){
var self = this, body = '', headers = {};
// https://developer.mozilla.org/En/HTTP_Access_Control
if (req.headers.origin && this._verifyOrigin(req.headers.origin)){
headers['Access-Control-Allow-Origin'] = '*';
headers['Access-Control-Allow-Credentials'] = 'true';
}
if (typeof req.headers['access-control-request-method'] !== 'undefined'){
// CORS preflight message
headers['Access-Control-Allow-Methods'] = req.headers['access-control-request-method'];
res.writeHead(200, headers);
res.write('ok');
res.end();
return;
socialcalc/third-party/Socket.IO-node/lib/socket.io/transports/xhr-polling.js view on Meta::CPAN
this._payload();
break;
case 'POST':
req.addListener('data', function(message){
body += message;
});
req.addListener('end', function(){
var headers = {'Content-Type': 'text/plain'};
if (req.headers.origin){
if (self._verifyOrigin(req.headers.origin)){
headers['Access-Control-Allow-Origin'] = '*';
if (req.headers.cookie) headers['Access-Control-Allow-Credentials'] = 'true';
} else {
res.writeHead(401);
res.write('unauthorized');
res.end();
return;
}
}
try {
socialcalc/third-party/Socket.IO-node/lib/socket.io/transports/xhr-polling.js view on Meta::CPAN
Polling.prototype._onClose = function(){
if (this._closeTimeout) clearTimeout(this._closeTimeout);
return Client.prototype._onClose.call(this);
};
Polling.prototype._write = function(message){
if (this._open){
var headers = {'Content-Type': 'text/plain; charset=UTF-8', 'Content-Length': Buffer.byteLength(message)};
// https://developer.mozilla.org/En/HTTP_Access_Control
if (this.request.headers.origin && this._verifyOrigin(this.request.headers.origin)){
headers['Access-Control-Allow-Origin'] = (this.request.headers.origin === 'null' ? '*' : this.request.headers.origin);
if (this.request.headers.cookie) headers['Access-Control-Allow-Credentials'] = 'true';
}
this.response.writeHead(200, headers);
this.response.write(message);
this.response.end();
this._onClose();
}
};