Merge branch 'master' into create-carto-package-json

This commit is contained in:
Simon Martín 2018-08-16 13:26:21 +02:00
commit 70030cae9d
2 changed files with 7 additions and 2 deletions

View File

@ -64,8 +64,13 @@ function handleCopyTo (logger) {
const { userDbParams, user } = res.locals;
const filename = req.query.filename || 'carto-sql-copyto.dmp';
// it is not sure, nginx may choose not to compress the body
// but we want to know it and save it in the metrics
// https://github.com/CartoDB/CartoDB-SQL-API/issues/515
const isGzip = req.get('accept-encoding') && req.get('accept-encoding').includes('gzip');
const streamCopy = new StreamCopy(sql, userDbParams);
const metrics = new StreamCopyMetrics(logger, 'copyto', sql, user);
const metrics = new StreamCopyMetrics(logger, 'copyto', sql, user, isGzip);
res.header("Content-Disposition", `attachment; filename=${encodeURIComponent(filename)}`);
res.header("Content-Type", "application/octet-stream");

View File

@ -1,7 +1,7 @@
const { getFormatFromCopyQuery } = require('../utils/query_info');
module.exports = class StreamCopyMetrics {
constructor(logger, type, sql, user, isGzip = null) {
constructor(logger, type, sql, user, isGzip = false) {
this.logger = logger;
this.type = type;