organise headers

This commit is contained in:
Simon Tokumine 2011-12-08 12:34:07 +00:00
parent 2bd532bc20
commit 9c6619f3e0

View File

@ -50,15 +50,7 @@ function handleQuery(req, res){
// setup step run
var that = this;
var start = new Date().getTime();
// allow cross site post
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
// set cache headers
res.header('Last-Modified', new Date().toUTCString());
res.header('Cache-Control', 'no-cache,max-age=3600,must-revalidate, public');
try {
if (!_.isString(sql)) throw new Error("You must indicate a sql query");
var pg;
@ -74,7 +66,6 @@ function handleQuery(req, res){
function setDBGetUser(err, data) {
if (err) throw err;
database = (data == "" || _.isNull(data)) ? database : data;
res.header('X-Cache-Channel', database);
oAuth.verifyRequest(req, this);
},
function querySql(err, user_id){
@ -109,6 +100,15 @@ function handleQuery(req, res){
// configure headers for geojson
res.header("Content-Disposition", getContentDisposition(format));
// allow cross site post
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
// set cache headers
res.header('Last-Modified', new Date().toUTCString());
res.header('Cache-Control', 'no-cache,max-age=3600,must-revalidate, public');
res.header('X-Cache-Channel', database);
// return to browser
res.send(out);
},