From 43885f130bd56adcd1d6fb16578eb48a53b7f472 Mon Sep 17 00:00:00 2001 From: David Manzanares Date: Fri, 6 Oct 2017 16:19:00 +0200 Subject: [PATCH] Fix HTTP status code distinction between 200 and 204 --- lib/cartodb/controllers/layergroup.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/cartodb/controllers/layergroup.js b/lib/cartodb/controllers/layergroup.js index f6089a00..ed0f3eb5 100644 --- a/lib/cartodb/controllers/layergroup.js +++ b/lib/cartodb/controllers/layergroup.js @@ -278,6 +278,10 @@ LayergroupController.prototype.tileOrLayer = function (req, res) { ); }; +function getStatusCode(tile, format){ + return tile.length===0 && format==='mvt'? 204:200; +} + // This function is meant for being called as the very last // step by all endpoints serving tiles or grids LayergroupController.prototype.finalizeGetTileOrGrid = function(err, req, res, tile, headers) { @@ -313,7 +317,7 @@ LayergroupController.prototype.finalizeGetTileOrGrid = function(err, req, res, t global.statsClient.increment('windshaft.tiles.error'); global.statsClient.increment('windshaft.tiles.' + formatStat + '.error'); } else { - this.sendResponse(req, res, tile, tile.length===0? 204:200, headers); + this.sendResponse(req, res, tile, getStatusCode(tile, formatStat), headers); global.statsClient.increment('windshaft.tiles.success'); global.statsClient.increment('windshaft.tiles.' + formatStat + '.success'); }