This commit is contained in:
Zellweger Christof Ralf
2015-12-22 13:12:03 +01:00
parent c6f2010d67
commit d9158a8868
4 changed files with 87 additions and 18 deletions
@@ -58,8 +58,7 @@ public class QueryRestConfig extends WebMvcConfigurerAdapter {
// a nested configuration
// this guarantees that the ordering of the properties file is as expected
// see:
// https://jira.spring.io/browse/SPR-10409?focusedCommentId=101393&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-101393
// see: https://jira.spring.io/browse/SPR-10409?focusedCommentId=101393&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-101393
@Configuration
@Import({QueryConfig.class})
static class InnerConfiguration {
@@ -9,6 +9,7 @@ import javax.servlet.http.HttpServletResponse;
import org.springframework.http.MediaType;
import ch.psi.daq.domain.ResponseFormat;
import ch.psi.daq.query.model.impl.DAQQuery;
@@ -42,11 +43,13 @@ public abstract class AbstractResponseStreamWriter implements ResponseStreamWrit
response.addHeader("Content-Type", contentType);
if (query.isCompressed()) {
response.addHeader("Content-Disposition", "attachment; filename=data.gz");
String filename = "data." + query.getCompression().getFileSuffix();
response.addHeader("Content-Disposition", "attachment; filename=" + filename);
response.addHeader("Content-Encoding", query.getCompression().toString());
out = query.getCompression().wrapStream(out);
} else {
response.addHeader("Content-Disposition", "attachment; filename=data.csv");
String filename = "data." + (query.getResponseFormat() == ResponseFormat.CSV ? "csv" : "json");
response.addHeader("Content-Disposition", "attachment; filename=" + filename);
}
return out;