diff --git a/lib/cartodb/controllers/base.js b/lib/cartodb/controllers/base.js index 9309de11..9a502bd4 100644 --- a/lib/cartodb/controllers/base.js +++ b/lib/cartodb/controllers/base.js @@ -7,10 +7,6 @@ module.exports = BaseController; // jshint maxcomplexity:9 BaseController.prototype.send = function(req, res, body, status, headers) { - if (res.locals.dbhost) { - res.set('X-Served-By-DB-Host', res.locals.dbhost); - } - res.set('X-Tiler-Profiler', req.profiler.toJSONString()); if (headers) { diff --git a/lib/cartodb/middleware/context/db-conn-setup.js b/lib/cartodb/middleware/context/db-conn-setup.js index 293ad586..90b76818 100644 --- a/lib/cartodb/middleware/context/db-conn-setup.js +++ b/lib/cartodb/middleware/context/db-conn-setup.js @@ -1,7 +1,7 @@ const _ = require('underscore'); module.exports = function dbConnSetupMiddleware(pgConnection) { - return function (req, res, next) { + return function dbConnSetup(req, res, next) { const user = res.locals.user; pgConnection.setDBConn(user, res.locals, (err) => { @@ -22,7 +22,8 @@ module.exports = function dbConnSetupMiddleware(pgConnection) { dbport: global.environment.postgres.port }); - + res.set('X-Served-By-DB-Host', req.params.dbhost); + req.profiler.done('req2params'); next(null); diff --git a/lib/cartodb/middleware/error-middleware.js b/lib/cartodb/middleware/error-middleware.js index 71f6c411..fd19e24f 100644 --- a/lib/cartodb/middleware/error-middleware.js +++ b/lib/cartodb/middleware/error-middleware.js @@ -31,10 +31,6 @@ module.exports = function errorMiddleware (/* options */) { errors_with_context: allErrors.map(errorMessageWithContext) }; - if (res.locals && res.locals.dbhost) { - res.set('X-Served-By-DB-Host', res.locals.dbhost); - } - res.set('X-Tiler-Profiler', req.profiler.toJSONString()); res.status(statusCode); diff --git a/test/unit/cartodb/prepare-context.test.js b/test/unit/cartodb/prepare-context.test.js index 97893291..fc8c9bd0 100644 --- a/test/unit/cartodb/prepare-context.test.js +++ b/test/unit/cartodb/prepare-context.test.js @@ -88,7 +88,7 @@ describe('prepare-context', function() { it('sets dbname from redis metadata', function(done){ var req = {headers: { host:'localhost' }, query: {} }; - var res = {}; + var res = { set: function () {} }; dbConnSetup(prepareRequest(req), prepareResponse(res), function(err) { if ( err ) { done(err); return; } @@ -104,7 +104,7 @@ describe('prepare-context', function() { it('sets also dbuser for authenticated requests', function(done){ var req = { headers: { host: 'localhost' }, query: { map_key: '1234' }}; - var res = {}; + var res = { set: function () {} }; // FIXME: review authorize-pgconnsetup workflow, It might we are doing authorization twice. authorize(prepareRequest(req), prepareResponse(res), function (err) {