diff --git a/lib/cartodb/controllers/named_maps.js b/lib/cartodb/controllers/named_maps.js index 05dba8f8..26c5e4ad 100644 --- a/lib/cartodb/controllers/named_maps.js +++ b/lib/cartodb/controllers/named_maps.js @@ -84,11 +84,11 @@ NamedMapsController.prototype.register = function(app) { tileBackend: this.tileBackend, label: 'NAMED_MAP_TILE' }), + setContentTypeHeader(), cacheControlHeader(), cacheChannelHeader(), surrogateKeyHeader({ surrogateKeysCache: this.surrogateKeysCache }), lastModifiedHeader(), - setContentTypeHeader(), sendResponse(), vectorError() ); @@ -115,12 +115,12 @@ NamedMapsController.prototype.register = function(app) { }), getStaticImageOptions({ tablesExtentApi: this.tablesExtentApi }), getImage({ previewBackend: this.previewBackend, label: 'STATIC_VIZ_MAP' }), + setContentTypeHeader(), incrementMapViews({ metadataBackend: this.metadataBackend }), cacheControlHeader(), cacheChannelHeader(), surrogateKeyHeader({ surrogateKeysCache: this.surrogateKeysCache }), lastModifiedHeader(), - setContentTypeHeader(), sendResponse() ); }; @@ -388,6 +388,14 @@ function getImage({ previewBackend, label }) { }; } +function setContentTypeHeader () { + return function setContentTypeHeaderMiddleware(req, res, next) { + res.set('Content-Type', res.get('content-type') || res.get('Content-Type') || 'image/png'); + + next(); + }; +} + function incrementMapViewsError (ctx) { return `ERROR: failed to increment mapview count for user '${ctx.user}': ${ctx.err}`; } @@ -444,11 +452,3 @@ function templateBounds(view) { } return false; } - -function setContentTypeHeader () { - return function setContentTypeHeaderMiddleware(req, res, next) { - res.set('Content-Type', res.get('content-type') || res.get('Content-Type') || 'image/png'); - - next(); - }; -}