Respond with 204 when vector tile is empty

This commit is contained in:
Daniel García Aubert
2017-07-17 19:44:18 +02:00
parent a35b1e3e86
commit eccc3597aa
3 changed files with 73 additions and 5 deletions
+11 -5
View File
@@ -525,7 +525,7 @@ TestClient.prototype.getTile = function(z, x, y, params, callback) {
};
var expectedResponse = {
status: 200,
status: params.status || 200,
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
@@ -542,7 +542,12 @@ TestClient.prototype.getTile = function(z, x, y, params, callback) {
if (isMvt) {
request.encoding = 'binary';
expectedResponse.headers['Content-Type'] = 'application/x-protobuf';
if (expectedResponse.status === 200) {
expectedResponse.headers['Content-Type'] = 'application/x-protobuf';
} else if (expectedResponse.status === 204) {
expectedResponse.headers['Content-Type'] = undefined;
}
}
var isGeojson = format.match(/geojson$/);
@@ -561,15 +566,16 @@ TestClient.prototype.getTile = function(z, x, y, params, callback) {
assert.response(server, request, expectedResponse, function(res, err) {
assert.ifError(err);
var obj;
if (isPng) {
obj = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
}
else if (isMvt) {
obj = new mapnik.VectorTile(z, x, y);
obj.setDataSync(new Buffer(res.body, 'binary'));
if (res.body) {
obj = new mapnik.VectorTile(z, x, y);
obj.setDataSync(new Buffer(res.body, 'binary'));
}
}
else {
obj = JSON.parse(res.body);