Send depending on body type

This commit is contained in:
Raul Ochoa 2015-09-17 02:04:30 +02:00
parent 31fe06e3ce
commit feabb20748

View File

@ -163,9 +163,19 @@ BaseController.prototype.send = function(req, res, body, status, headers) {
res.set(headers); res.set(headers);
} }
res.send.apply(res, args); res.status(status);
if (req.profiler ) { if (!Buffer.isBuffer(body) && typeof body === 'object') {
if (req.query && req.query.callback) {
res.jsonp(body);
} else {
res.json(body);
}
} else {
res.send(body);
}
if (req.profiler) {
try { try {
// May throw due to dns, see // May throw due to dns, see
// See http://github.com/CartoDB/Windshaft/issues/166 // See http://github.com/CartoDB/Windshaft/issues/166