<commit_before>/* Standard data sender */

var debug = require('nor-debug');
var plugins = require('../plugins');

module.exports = function senders_standard() {
	//debug.log('here');
	return function json_sender(data, req, res, next) {
		//debug.log('here');
		// Send as JSON
		try {
			debug.assert(data).is('object');
			debug.assert(req).is('object');
			debug.assert(res).is('object');
			debug.assert(next).is('function');

			var content;

			if(req.headers['x-pretty-print'] || req.headers['x-pretty-json']) {
				content = JSON.stringify(data, null, 2);
			} else {
				content = JSON.stringify(data);
			}

			if(content) {
				res.type('application/json');
				res.send(content + '\n');
			}
		} catch(err) {
			debug.error(err);
			plugins.send_error({"code":500, "error":"Internal Server Error"})(req, res);
		}
	};
};
/* EOF */<commit_msg>Fixed content type charset problem<commit_after>/* Standard data sender */

var debug = require('nor-debug');
var plugins = require('../plugins');

module.exports = function senders_standard() {
	//debug.log('here');
	return function json_sender(data, req, res, next) {
		//debug.log('here');
		// Send as JSON
		try {
			debug.assert(data).is('object');
			debug.assert(req).is('object');
			debug.assert(res).is('object');
			debug.assert(next).is('function');

			var content;

			if(req.headers['x-pretty-print'] || req.headers['x-pretty-json']) {
				content = JSON.stringify(data, null, 2);
			} else {
				content = JSON.stringify(data);
			}

			if(content) {
				res.set('content-type', 'application/json;charset=utf-8');
				res.send(content + '\n');
			}
		} catch(err) {
			debug.error(err);
			plugins.send_error({"code":500, "error":"Internal Server Error"})(req, res);
		}
	};
};
/* EOF */
{'fraction_non_alphanumeric': 0.20648464163822525, 'fraction_numerical': 0.005119453924914676, 'mean_word_length': 3.6534391534391535, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '202560', 'n_tokens_mistral': 692, 'n_tokens_neox': 589, 'n_words': 109}