/*
* pnhandler.js
*
* group of methods that handles different pathnames
*/
var util = require('util');
var querystring = require('querystring');
function noop(query, reqdata, res) {
util.log('[pnhandler] handling ' + query.pathname +
', ok who the fuck is messing with us?');
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end();
}
function register(query, reqdata, res) {
util.log('[pnhandler] handling ' + query.pathname);
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end();
}
function login(query, reqdata, res) {
util.log('[pnhandler] handling ' + query.pathname);
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end();
}
function poll(query, reqdata, res) {
util.log('[pnhandler] handling ' + query.pathname);
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end();
}
function upload(query, reqdata, res) {
util.log('[pnhandler] handling ' + query.pathname);
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end();
}
function info(query, reqdata, res) {
util.log('[pnhandler] handling ' + query.pathname);
var body =
'\n' +
'\n' +
'
\n' +
'Info\n' +
'\n' +
'\n' +
'\n' +
'Node.JS Server Info
' +
'Node ' + process.version + ', uptime ' + process.uptime() + ' seconds' + '
' +
'Memory usage: ' + process.memoryUsage().heapTotal / (1024*1204) + 'MB
' +
'\n' +
'\n';
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(body);
res.end();
}
function hello(query, reqdata, res) {
util.log('[pnhandler] handling ' + query.pathname);
var body =
'\n' +
'\n' +
'\n' +
'Hello\n' +
'\n' +
'\n' +
'\n' +
'\n' +
'\n' +
'\n';
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(body);
res.end();
}
function hellores(query, reqdata, res) {
util.log('[pnhandler] handling ' + query.pathname);
util.log('[pnhandler] hello recv:\n' + querystring.parse(reqdata).text);
var body =
'\n' +
'\n' +
'\n' +
'Hello Response\n' +
'\n' +
'\n' +
'\n' +
'You requested/sent:
' +
querystring.parse(reqdata).text +
'\n' +
'\n';
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(body);
res.end();
}
exports.noop = noop;
exports.register = register;
exports.login = login;
exports.poll = poll;
exports.upload = upload;
exports.info = info,
exports.hello = hello;
exports.hellores = hellores;