Fix HTTP status code distinction between 200 and 204

This commit is contained in:
David Manzanares 2017-10-06 16:19:00 +02:00
parent 58be2b8fc5
commit 43885f130b

View File

@ -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');
}