Advertise header presence in CSV Content-Type

This commit is contained in:
Sandro Santilli 2012-10-25 13:40:21 +02:00
parent a6837573c5
commit 978c0b4cbe
2 changed files with 4 additions and 2 deletions

View File

@ -203,7 +203,7 @@ function handleQuery(req, res) {
function setHeaders(err, result){
if (err) throw err;
// configure headers for geojson/CSV
// configure headers for given format
res.header("Content-Disposition", getContentDisposition(format));
res.header("Content-Type", getContentType(format));
@ -609,7 +609,7 @@ function getContentDisposition(format){
function getContentType(format){
var type = "application/json; charset=utf-8";
if (format === 'csv'){
type = "text/csv; charset=utf-8";
type = "text/csv; charset=utf-8; header=present";
}
else if (format === 'svg'){
type = "image/svg+xml; charset=utf-8";

View File

@ -555,6 +555,8 @@ test('CSV format', function(done){
var cd = res.header('Content-Disposition');
assert.equal(true, /^attachment/.test(cd), 'CSV is not disposed as attachment: ' + cd);
assert.equal(true, /filename=cartodb-query.csv/gi.test(cd));
var ct = res.header('Content-Type');
assert.equal(true, /header=present/.test(ct), "CSV doesn't advertise header presence: " + ct);
done();
});
});